Reputation: 7984
I have ImageButton that has a scr from an image I added to the drawble-hdpi folder called imgholder, this image Width = 96pix and Height = 96px
but when I check on the Height and Width for the ImageButton in its click event I get 128!
Why is that? where did the extra came from and how to resolve this so the ImageButton has same width as the src image. Thanks
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/ibAddImage1"
android:src="@drawable/imgholder"
android:layout_above="@+id/tvAddReviseCaption"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:background="@android:color/transparent" />
Upvotes: 1
Views: 2325
Reputation: 154
"px" changes device to device. You should use dp for layout_width and layout_height android:layout_width="96dp" android:layout_height="96dp"
Upvotes: 1