仪表板布局不适合我,因此我建议使用基于布局的解决方案。
只是版面中的一堆版面。
关键是间距布局和内容布局之间权重的相关性。
您可以非常简单地移动图标,并为更大或更轻的仪表板定义其他布局。
下面是它的样子:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/dashboard"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<FrameLayout style="@style/dashboard_space_vertical" />
<LinearLayout style="@style/dashboard_content_vertical" >
<FrameLayout style="@style/dashboard_space_horizontal" >
</FrameLayout>
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 1" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 2" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_vertical" />
<LinearLayout style="@style/dashboard_content_vertical" >
<FrameLayout style="@style/dashboard_space_horizontal" />
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 3" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 4" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_vertical" />
<LinearLayout style="@style/dashboard_content_vertical" >
<FrameLayout style="@style/dashboard_space_horizontal" />
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 5" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
<LinearLayout style="@style/dashboard_content_horizontal" >
<ImageView
style="@style/dashboard_imageview"
android:src="@android:drawable/sym_call_missed" />
<TextView
style="@style/dashboard_textview"
android:text="Text 6" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_horizontal" />
</LinearLayout>
<FrameLayout style="@style/dashboard_space_vertical" />
</LinearLayout>
以下是样式:
<resources>
<style name="dashboard_space_vertical">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">0px</item>
<item name="android:layout_weight">1</item>
</style>
<style name="dashboard_content_vertical">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">0px</item>
<item name="android:layout_weight">3</item>
<item name="android:layout_gravity">center</item>
</style>
<style name="dashboard_space_horizontal">
<item name="android:layout_width">0px</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">2</item>
</style>
<style name="dashboard_content_horizontal">
<item name="android:layout_width">0px</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">3</item>
<item name="android:orientation">vertical</item>
<item name="android:layout_gravity">center</item>
<item name="android:gravity">center</item>
</style>
<style name="dashboard_imageview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">fill_parent</item>
<item name="android:layout_weight">1</item>
<item name="android:scaleType">fitCenter</item>
</style>
<style name="dashboard_textview">
<item name="android:layout_width">fill_parent</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:gravity">center</item>
<item name="android:textSize">@dimen/dashboard_thumbnail_text_size</item>
<item name="android:textStyle">bold</item>
<item name="android:textColor">@color/blue</item>
</style>
</resources>
希望这对别人有帮助。好好享受。