2014-11-09 56 views
1

當我鼠標移到LinearLayout我得到一個警告更換,我怎麼能擺脫它?此標記和它的孩子們可以通過一個<TextView/>和複方繪製

這個標籤及其子可以通過一個TextView的/>和 複方繪製

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    > 

    <ImageView 
     android:id="@+id/frag1_icon" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     /> 

    <TextView 
     android:id="@+id/frag1_text" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="10dp" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

</LinearLayout> 

回答

1

這已經回答了herehere
合併的TextView和ImageView的在被替換一個視圖,在代碼中使用TextView的setCompoundDrawable *()方法,或者在xml中使用android:drawableLeft等。
添加

android:drawableLeft="@drawable/image" 

你的TextView並刪除ImageView的。
UPDATE:
answer given here
這只是一個警告,應用程序仍然應該編譯並運行。但是,這並不意味着您只想解除所有警告。 你可以在你的xml中使用drawableLeft。像

<TextView 
    android:id="@+id/txt1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_marginLeft="10dp" 
    android:text="text1 " 
    android:textColor="#fff" 
    android:textSize="@dimen/sizeNormal" 
    android:drawableLeft="@drawable/tick /> 
+0

對不起,我遲到的答案,我一直在忙於學校。我試圖讓它工作,但我不能將TextView與ImageView合併...我沒有任何可繪製的那兩個。我看了谷歌的方式來做到這一點,但沒有找到一個... – Alec 2014-11-11 16:42:54

+0

複合視圖需要繪製。 – 2014-11-11 17:59:07

相關問題