[英]Put a TextView in front of a ImageView
Im searching a way how to fix a TextView on a ,for example, transparent square like in the Picture I did in Paint.net .So the TextView should in front of the transparent square (ImageView).Also it should stretch when the screen is bigger. 我正在寻找一种方法如何修复TextView,例如透明方块,就像我在Paint.net中做的图片一样。因此TextView应该在透明方块(ImageView)前面。当屏幕是大。
http://www7.pic-upload.de/22.02.14/24vtze5ulxc2.png http://www7.pic-upload.de/22.02.14/24vtze5ulxc2.png
How can I solve the problem ? 我该如何解决这个问题? Thanks !
谢谢 !
Use a FrameLayout 使用FrameLayout
<FrameLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/semi_transparent_background"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="This is my text."/>
</FrameLayout>
Alternatively, you could do something similar with a relative layout. 或者,您可以使用相对布局执行类似的操作。
You can use RelativeLayout or FrameLayout for that. 您可以使用RelativeLayout或FrameLayout。
<FrameLayout>
<ImageView>
<TextView>
</FrameLayout>
Your textview will appear on ImageView. 您的textview将出现在ImageView上。
Although note that, RelativeLayout has double taxation tradeoff. 虽然注意到,RelativeLayout有双重征税权衡。 Each measure and layout happens twice.
每个度量和布局都会发生两次。
简单地在XML中从上到下排序RelativeLayout中的项目将使每个项目与其上方的其他项目相比向前移动。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.