0

I can now have a button that contains a single image icon and text, just like below (the red square is the image):

enter image description here

<Button
    android:id="@+id/btn"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:background="@drawable/shadow"
    android:drawableLeft="@drawable/redsquare"
    android:drawablePadding="6dp"
    android:text="Text goes here"
    android:textColor="@android:color/white"
    android:textSize="14dp"
    android:textAllCaps="false"
    android:gravity="left|center" />

However, I want to have the button as shown below (two small red squares are two different images):

enter image description here

I tried to add another drawable in the button, but the result is not as expected. May I ask how can I achieve the same result as above button, please?

2
  • 1
    Easiest way would be to define the UI in a layout XML, and add this line to the parent layout: android:theme="@android:style/Widget.Button". I think RelativeLayout would be the best here. Commented Aug 19, 2018 at 8:32
  • Any details would be appreciated! Commented Aug 19, 2018 at 8:43

1 Answer 1

1

Better approach would be to use an custom button or custom view with either ripple effect or custom button selector added to the view.

Sign up to request clarification or add additional context in comments.

1 Comment

I am trying to add an ImageView on button, but the image cannot be shown. Do you know why?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.