0
我試圖圍繞Android中的兩個TextView對象繪製一個框。在此之前,我在LinearLayout中使用了兩個TextView,但我正致力於展平視圖層次結構以提高性能。當他們在LinearLayout中時,背景會根據需要顯示出來,但是當我創建具有相同尺寸的空白布局時,我根本沒有看到背景。
我的猜測是這是因爲FrameLayout中沒有任何東西(我也嘗試了一個空的LinearLayout)。我也嘗試在運行時設置此值,但結果相同。佈局中的背景不出現,除非我把佈局中的東西
這在Eclipse的佈局編輯器中工作正常,但是在我的平板電腦上運行時,背景只是不存在。
任何建議來完成相同的事情或任何建議,我失蹤將有所幫助。這裏的形狀:
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<solid android:color="#508E8F8E" />
<stroke
android:width="1dip"
android:color="#8E8F8E" />
<corners android:radius="4dp" />
</shape>
而這裏的佈局:
<FrameLayout
android:id="@+id/box_around_text"
android:layout_width="35dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:background="@drawable/background_gray"/>
<TextView
android:id="@+id/first_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="first_text" />
<TextView
android:id="@+id/second_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/first_text"
android:text="second_text" />
你是否也在em see中看到過?如果是的話,使用hierarchyviewer來找出最新的錯誤 – pskink 2014-10-11 18:58:35