I'm using two buttons in my list. One is a ToggleButton
and the other is a regular ImageButton
Here is how I've set it in the XML:
<ToggleButton android:id="@+id/favc"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#ffffff"
android:padding="15dp"
android:layout_gravity="center"
android:focusable="false"
android:layout_marginRight="10dp"
android:textOn="" android:textOff=""
/>
<ImageButton
android:id="@+id/edit"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="#ffffff"
android:gravity="center"
android:focusable="false"
android:layout_marginRight="10dp"
android:layout_alignParentLeft="true"
android:padding="15dp"
android:src="@drawable/pencil"/>
The logic for toggling the button is in my list adapter:
if (holder.favButton.isChecked())
holder.favButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.star_pressed));
else
holder.favButton.setBackgroundDrawable(getResources().getDrawable(R.drawable.star_1));
Question/Problem
Everything works fine on a regular sized screen. However, when I test this on a tablet, the ToggleButton
is really big in size compared to the ImageButton
. I've verified the image size for all the res folders. This is what I have:
hdpi = 24 x 24 (pencil), 24 x 23 (star)
mdpi = 16 x 16 (pencil), 16 x 15 (star)
xhdi = 32 x 32 (pencil), 34 x 32 (star)
xxhdi = 42 x 42 (pencil), 51 x 48 (star)
This is how it looks on tablet
This is how it looks on normal phone
Instead of 32dp
I've tried wrap_content
as well but that did not help either.