Android bouton avec l'icône et le texte

J'ai des boutons comme ça dans mon application:

    <Button
        android:id="@+id/bSearch"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:padding="16dp"
        android:text="Search"
        android:textSize="24sp" />

Je suis en train de créer un bouton avec un texte et une icône.
android:drawableLeft ne fonctionne pas pour moi (il a Peut-être, mais je ne sais pas comment mettre un max de la hauteur de l'icône).

J'ai donc créé un LinearLayout avec une ImageView et un TextView et fait-il agir comme un bouton:

    <LinearLayout
        android:id="@+id/bSearch2"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/btn_default"
        android:clickable="true"
        android:padding="16dp"
        android:orientation="horizontal" >

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:layout_marginLeft="5dp"
            android:adjustViewBounds="true"
            android:maxHeight="30dp"
            android:maxWidth="30dp"
            android:scaleType="fitCenter"
            android:src="@drawable/search_icon" />

        <TextView
            android:id="@+id/tvSearchCaption"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:textSize="24sp"
            android:paddingRight="30dp"
            android:gravity="center"
            android:text="Search" />
    </LinearLayout>

Mon nouveau bouton est exactement ce que je veux (taille de la police, l'icône et le texte de l'emplacement).
Mais il ne ressemble pas à mes boutons par défaut:

Android bouton avec l'icône et le texte

J'ai donc essayé, pour changer l'arrière-plan et la couleur du texte de mon Bouton nouveau:

Button Search = (Button) findViewById(R.id.bSearch);
LinearLayout bSearch2 = (LinearLayout) findViewById(R.id.bSearch2);
bSearch2.setBackground(bSearch.getBackground());
TextView tvSearchCaption = (TextView)findViewById(R.id.tvSearchCaption);
tvSearchCaption.setTextColor(bSearch.getTextColors().getDefaultColor());

Cela donne un résultat étrange, mon vieux bouton, se foiré:

Android bouton avec l'icône et le texte

Quand j'ai changer l'ordre de ces deux boutons dans le XML, de sorte que le "nouveau bouton" va d'abord, il fait un autre résultat étrange:

Android bouton avec l'icône et le texte

Maintenant, j'ai remarqué, que quand j'ai essayer d'appuyer sur le vieux bouton, la nouvelle se pressé.

Des idées?

InformationsquelleAutor Dusan | 2014-04-09