I’m trying to implement DashboardLayout (Pattern 3).
All ok when orientation is portrait:

But when orientation of app changes to album it looks like:

Here is the source code of DashboardLayout.java
Activity layout file as in example:
<?xml version="1.0" encoding="utf-8"?>
<com.example.ui.DashboardLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white" >
<Button
android:id="@+id/posts"
style="@style/DashboardButton"
android:drawableTop="@drawable/ic_db_posts"
android:onClick="onClick"
android:text="posts" />
***and four same buttons***
</com.example.ui.DashboardLayout>
style/DashboardButton:
<style name="DashboardButton">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center_horizontal</item>
<item name="android:layout_gravity">center_vertical</item>
<item name="android:background">@drawable/db_buttons</item>
<item name="android:textStyle">bold</item>
<item name="android:textSize">16sp</item>
<item name="android:textColor">#000000</item>
</style>
Background only for button pressed state:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item
android:state_pressed="true"
android:drawable="@drawable/db_button_bd_pressed" />
</selector>
Pressed:
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<padding
android:left="10dp"
android:top="20dp"
android:right="10dp"
android:bottom="20dp" />
<corners android:radius="10dp" />
<solid android:color="#a6cee1" />
</shape>
Where is the problem? Help me, please.
The Dashboardlayout just works if the number of buttons is even. You have an odd number, just insert an extra button with:
So it will handle it like a extra button but it is transparent.