I created an app where I use Google Books API in it.
As part of the attributions they require, I need to add to each query results the following button:
Now, I wanted to use that Image as a background to a button but I got this results:
As you can see it seems to be stretched with bad quality.
The xml I used is:
<ImageButton
android:id="@+id/tv_Link"
android:layout_width="wrap_content"
android:layout_height="24dp"
android:layout_alignStart="@+id/imagecard"
android:layout_alignEnd="@+id/imagecard"
android:layout_alignBottom="@+id/imagecard"
android:background="@drawable/gbs_preview_button"
android:elevation="50dp"
android:fontFamily="@font/assistant_semibold"
android:gravity="center"
android:textColor="@color/colorLightPurple"
android:textSize="8sp" />
In order to fix it, I decided to use bitmap:
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
android:gravity="center"
android:src="@drawable/gbs_preview_button"
android:tileMode="disabled"/>
The problem is that it became small like this (good quality, but small):
This dimension is too small since they require the height to be 24dp.
Is there any way I can add this image to the button, to make it 24dp height and still to keep the quality of the image?
Thank you
As you want to hardcode the height to 24dp
, then you can also hardcode the width to a value that keeps the aspect ratio of the original image size which is (88 x 31).
So, set the width to 68dp
instead of wrap_content