I want to do the Dashboard pattern. I currently do this for each home button:
<FrameLayout
android:layout_weight="1"
android:focusable="true"
android:onClick="onHomeButtonClicked"
android:background="@drawable/button_background">
<TextView
android:text="@string/button_text"
android:drawableTop="@drawable/button_icon"
android:layout_gravity="center"
android:gravity="center"
android:background="@android:color/transparent" />
</FrameLayout>
The reason I wrap my button inside a FrameLayout is I want to:
- Maximize the clickable area
- Make the icon and text properly centered.
I tried doing this in the past but gave up because I couldn't figure out a screensize-independent way of centering the text and icon:
<Button
android:layout_weight="1"
android:background="@drawable/button_background"
android:text="@string/button_text"
android:onClick="onHomeButtonClicked"
android:drawableTop="@drawable/button_icon"
android:drawablePadding="DONT_KNOW_WHAT_TO_PUT_IN_HERE" />
My question: Is it possible to do all these:
- Not wrap the Button inside other layout (using only 1 view per button)
- Maximize the clickable area
- Properly center the icon and text in a screensize-independent way
Many thanks.