1
Eclipse的Android應用程序 我試圖做的「方形」按鈕的菜單 - 3個按鈕在一排 - 每個按鈕都有一個背景圖片...日食 - Android的APP-廣場磚菜單
我能夠製作相同重量的列,但我無法弄清楚如何使按鈕的高度始終等於它們的寬度,因爲: - 我將在未來添加更多行到應用程序,所以我不希望佈局是特定於一定數量的行;即:無論行數是多少,這些按鈕都應該是正方形的(當然,在任何設備屏幕尺寸上) - 我希望背景圖像自己調整到按鈕;即:按鈕仍然是一個正方形和背景圖像符合它
這是到目前爲止我的代碼(只有三個行具有相同背景圖片
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:overScrollMode="never" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:background="@drawable/velocity_icon"
/>
</LinearLayout>
</LinearLayout>
</ScrollView>
菜單,這樣的:http://radleymarx.com/blog/simple-引導到9的貼劑/ – SRah