Hallo ich habe Knopf mit zwei Bildern, die nach links und rechts zeichnbar sind, ich möchte nur linkes Seitenbild entfernen, und will das rechte Seitenbild behalten, mein Knopf xml Code ist unten.Programmatisch entfernen Sie das Bild auf der linken Seite der Schaltfläche, aber nicht auf der rechten Seite?
<Button
android:id="@+id/fragment_add_to_cart_btn_proceed_to_checkout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/colorRed"
android:drawableEnd="@drawable/ic_action_next"
android:drawablePadding="5dp"
android:drawableStart="@drawable/ic_rounded_cart"
android:gravity="left|center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="@string/proceed_to_checkout"
android:textColor="@color/colorWhite" />
Ich habe einige Code wie unten angewendet, aber es ist nicht
button.setCompoundDrawables(null, null, null, null);
arbeiten, wenn Sie eine Lösung haben, antworten Sie bitte? danke.
Entfernen Sie einfach die folgende Zeile: 'android: drawableStart = "@ ziehbar/ic_rounded_cart"' –
Ich möchte dies programmatisch tun. –
Verwenden Sie dann 'button.setCompoundDrawablesWithIntrinsicBounds (null, null, Ihr_rechts_Zeichensatz, null); 'Referenz: https://developer.android.com/reference/android/widget/TextView.html#setCompoundDrawablesWithIntrinsicBounds(int,%20int,%20int, % 20int) –