1

When I move mouse over LinearLayout I get a warning, how can I get rid of it?

This tag and its children can be replaced by one TextView/> and a compund drawable

<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>
Alec
  • 347
  • 2
  • 9
  • 29

1 Answers1

1

This has been answered here and here
Combine the TextView and the ImageView in to a single view, using TextView's setCompoundDrawable*() methods in code, or using android:drawableLeft,etc in xml.
Add

android:drawableLeft="@drawable/image" 

to your textview and remove the imageview.
UPDATE:
From answer given here.
This is just a warning and the app should still compile and run. However, this doesn't mean that you just want to dismiss all warnings. You could use drawableLeft in your xml. Something like

<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 />
Community
  • 1
  • 1
Mohammed Ali
  • 2,758
  • 5
  • 23
  • 41
  • Sorry for my late answer, I've been busy with school. I tried to get it working but I just can't merge the the TextView with the ImageView... I don't have any drawable in those two. I looked on google for a way to do it but didn't found one... – Alec Nov 11 '14 at 16:42
  • drawable is needed for the compound view. – Mohammed Ali Nov 11 '14 at 17:59