Android imagebutton how to resize icon

Recently, I have been working on interfaces, and I have a lot of problems with image sizes. I am very poor at materials, and I have serious problems with Android Android icons. So I have some questions regarding them.

First of all, this is my current layout:

enter image description here

As you can see, I have two icons of different sizes, and this is not very good. I can’t get them to be the same size.

My questions:

1 - How to make them take one size?

2 - What are the recommended size differences for hdpi, ldpi, mdpi and xhdpi?

3 - Why, if I set the imageButton background color to the same color as the layout background, does the icon move as if there was no button in the background?

Example: enter image description here

Thanks in advance!

+5
4

, ( src):

android:background="@drawable/image_name"

:

android:layout_height="10dp" //or any size required
android:layout_width="10dp" //or any size required ... let these 2 sizes be same for both the ImageButtons

"dp" "dip" - .

, .

+6

:

java:

YOUR_VIEW.setLayoutParams(new LayoutParams(width,height));

XML:

android:layout_height="10px"
android:layout_width="10px"
+1
android:layout_height="10dp"

android:layout_width="10dp"

px, dp

+1

All Articles