1
這兩個屬性都是以編程方式設置的。我嘗試重新啓動,當設置TextView背景時更改AVD - bu - 文本消失。是的,它有不同的顏色,然後背景。沒有背景文字是可見的。我不知道問題出在哪裏?在Android中設置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項目的一部分 - 但我不認爲這是問題。
隨着背景:
無背景:
事實上,有2個TextViews,一個表示距離和第二號碼 - 第一個沒有背景。當我嘗試爲第二個背景添加背景時 - 兩個文本都消失了。
嘗試使用機器人:layout_height =「WRAP_CONTENT」。然後嘗試 – 2012-03-04 14:07:03
仍然無法正常工作 – Darko 2012-03-04 14:09:07
然後更改安卓重力=「CENTER_HORIZONTAL」,並嘗試 – 2012-03-04 14:16:35