如何设置放在ImageView上的textview的背景不透明度 [英] How to set background opacity of a textview placed on to of ImageView
问题描述
在名称的背景透明的情况下,我想获得以下结果.
I would like to achieve the following result where there is a transparent background over the name.:
到目前为止,这是我所做的(忽略图像周围的黑色边框):
So far this is what i have done (ignore the black border surrounding the image):
我想有一个透明的背景(实际上是一个不透明度调整过的彩色背景).
i would like to have a transparent background (actually a colored background with its opacity adjusted).
这是我一直在使用的XML代码:
Here is the XML code i have been using:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="5dp">
<ImageView
android:id="@+id/iconItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_gravity="center"
android:src="@drawable/shout_ic"/>
<TextView
android:id="@+id/textItem"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_alignBottom="@+id/iconItem"
android:paddingBottom="5dip"
android:textSize="10sp"
android:textColor="#FFF"/>
</RelativeLayout>
有人能指出我如何实现这些目标的正确方向吗?谢谢
Can anyone points me to the right direction on how to achieve such things? Thx
推荐答案
在您的TextView定义中,添加:
In your TextView definition, add:
android:background="#8888"
888为中灰(888888),其中8为中灰(88)
888 being a mid grey (888888), with 8 being a mid alpha (88)
OR
android:background="#8000"
000为黑色(000000),其中8为中字母(88)
000 being a black (000000), with 8 being a mid alpha (88)
这篇关于如何设置放在ImageView上的textview的背景不透明度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!