0

I have found an answer to a question how to create heart shaped button using vector xml.

Answer is here: https://stackoverflow.com/a/45618554/8523262

But I am not able to get it correctly implemented in my case.

I have two buttons side by side third would be this heart-Button. However, it does not fit correctly with other two buttons. I need it smaller than what original answer has it.

Here is my xml

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:padding="7sp"
    android:textSize="12sp"
    >

    <Button
        android:id="@+id/buttonIA"
        android:layout_width="0sp"
        android:layout_weight=".3"
        android:layout_height="25sp"
        android:background="@drawable/buttondesign"
        android:textColor="@color/white"
        android:text="Hide Arabic Version"
        />

    <Button
        android:id="@+id/buttonIR"
        android:layout_width="0sp"
        android:layout_weight=".3"
        android:layout_height="25sp"
        android:background="@drawable/buttondesign"
        android:textColor="@color/white"
        android:layout_marginStart="7sp"
        android:text="Hide Reference"
        />
    <Button
        android:id="@+id/buttonF"
        android:layout_width="0sp"
        android:layout_weight="0.3"
        android:layout_height="25sp"
        android:background="@drawable/buttondesign"
        android:textColor="@color/white"
        android:layout_marginStart="7sp"
        android:text="Favorite it!"
        />
</LinearLayout>

Can anyone please tell me to resize it to look like a heart when placed inline with the two buttons I have already.

ButtonF is what I tried to set this vector as background of. Changed height/width too but didn't get it how i need it.

Thank you.

Abu Qatada
  • 211
  • 3
  • 16

1 Answers1

0

I use ImageButton Button instead of Button now. You could use ImageView too. favoritebutton in below code is the vector xml that I shared link of in my questions, in case it helps anyone.

        <ImageButton
        android:id="@+id/buttonF"
        android:layout_weight=".3"
        android:layout_width="24dp"
        android:layout_height="24dp"
        android:src="@drawable/favoritebutton"
        android:textColor="@color/white"
        android:layout_marginStart="7dp"
        android:background="@null"
     />
Abu Qatada
  • 211
  • 3
  • 16