这两个属性是通过编程设置的。我尝试重新启动、更改AVD,但仍然存在问题:当TextView背景设置后,文本会消失。是的,它的颜色与背景不同。没有背景时,文本是可见的。我不知道问题出在哪里...
{下面的代码可以正常运行}
<TextView
android:id="@+id/txt_Number"
android:layout_width="match_parent"
android:layout_height="25dp"
android:gravity="center"
android:text="1"
android:textColor="@color/red"
android:textSize="10sp"
android:textStyle="bold" />
此代码仅显示背景,没有文本 :/
<TextView
android:id="@+id/txt_Number"
android:layout_width="match_parent"
android:layout_height="25dp"
android:gravity="center"
android:text="1"
android:background="@drawable/txtbg"
android:textColor="@color/red"
android:textSize="10sp"
android:textStyle="bold" />
该图片以PNG格式具有背景透明度。TextView位于TableLayout中的TableRow内部。该布局是ListView项的一部分 - 但我不认为这是问题所在。
带背景图:
![enter image description here](https://istack.dev59.com/xzegD.webp)
![enter image description here](https://istack.dev59.com/1Iv0v.webp)
100m
,有时候又不会?你确定要显示的数据是正确的吗?在你的代码中如何设置文本? - WarrenFaith