黑颜色来代替安卓
为TextView的透明背景下面的两个图片都是的TextView具有以下属性在里面:黑颜色来代替安卓
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/button_style"
android:text="select password"
android:textColor="@color/dif_black"/>
和button_style.xml是
<?xml version="1.0" encoding="UTF-8"?>
<layer-list >
<item>
<shape>
<stroke
android:width="2dp"
android:color="#88C425" />
<corners android:radius="20dp" />
</shape>
</item>
第一张照片取自帆布2,第二张照片取自三星银河发我 。这里是我不希望在边框(笔画)边框内填充黑色的问题。您会在第一张图片中注意到textview的背景是透明的。我想在所有的Android设备中都是透明的背景。
您只指定行程形状,但它需要背景。看起来黑色是默认的。
通过添加固体透明背景更改button_style.xml形状:
<shape>
<stroke
android:width="2dp"
android:color="#88C425" />
<corners android:radius="20dp" />
<solid android:color="@android:color/transparent" />
</shape>
如果需要透明的颜色则U需要像这样定义
android:background="#ffffffff"
对于防爆
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:text="select password"
android:textColor="#efyfff"/>
或者somply U可以设置你的背景为白色
android:background="@color/white"
更新::
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:text="select password"
android:textColor="#efyfff"/>
你看到了图片吗? –
我需要看背景如果我给'#FFFFFFFF'那么显然它会是白色的。要看到背景,我必须使用'@android:color/transparent',这是我完成我的工作的地方。但我应该在我的** button_style.xml中使用它**不直接在'TextView'中,因为您在这里提到 –
如上所述使用“android:background =”#ffffffff“”设置您的背景 – AndroidHacker
对于一个简单的TextView,你可以做到这一点.... (TextView的)txtListChild.setBackgroundColor(Color.TRANSPARENT);
但是,如果你正在使用一个ListView,你需要找到ItemView控件布局被用于每个项目并设置有......像这样的事情
if (convertView == null) {
LayoutInflater infalInflater = (LayoutInflater) this._context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.list_item, null);
convertView.setBackgroundColor(Color.TRANSPARENT);
}
你需要指定应用主题像Light.NoTitleBar等... –
你的TextView的背景颜色可能是透明的,因为你现在甚至需要。但是如果三星Galaxy Fame的应用主题是黑色呢?然后你会看到黑色的TextView的透明背景,对吧? –
终于明白了。我将下面的代码添加到了我的样式属性的''标记中。 ' ' –