-1

I am using ImageButton in my custom bottom navigation. And I have set icons of 32*32 size as src to them.

here is xml

 <ImageButton
        android:id="@+id/bottom_nav_profile"
        android:layout_width="match_parent"
        android:layout_height="50sp"
        android:layout_weight="1"
        android:src="@drawable/btm_nav_user_act"
        android:text="Profile"
        android:adjustViewBounds="true"
        android:scaleType="center"
        android:background="@drawable/bottom_nav_bg"
        android:textColor="#000"/>

When I view it on my phone they look pixelated. I'm fine them being smaller but I dont want them to be pixelated. How can I make adujustment so that they look sharper.

Here are the icons

enter image description here enter image description here

vikas devde
  • 11,691
  • 10
  • 35
  • 42

2 Answers2

0

It seems that your image is very small to begin with, you have 2 options:

  • Remove the hardcoded height (50dp), your original image may be smaller than this, forcing its height may be reducing its quality on certain devices.

  • Have the same drawable you're using but for different phone densities. I'm guessing you only have one version of your drawable image in the drawable folder, on certain phones with certain densities, this image may display badly (just as it may be displayed just fine on certain other phones).

Husayn Hakeem
  • 4,184
  • 1
  • 16
  • 31
0

Lets make custom Image Button with linear layout and imageview

<LinearLayout
            android:id="@+id/id"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:orientation="vertical">
            <ImageView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                 android:src="@drawable/btm_nav_user_act"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="Profile"
                android:textColor="#000"/>


        </LinearLayout>

Now use linear layout as a button.