【发布时间】:2011-02-26 06:04:49
【问题描述】:
我想做一个类似这样的布局:
www.ImageBanana.net - layout.png http://www.imagebanana.com/img/9kmlhy66/thumb/layout.png
屏幕上有四个方形按钮 - 每个按钮都使用屏幕高度的一半(以较小者为准)。与屏幕尺寸/分辨率无关。
我已经尝试通过使用 LinearLayout 来实现这一点,但按钮最终使用了正确的宽度,但仍然具有背景的高度(不再是正方形)。
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_width="fill_parent"
android:text="@string/sights"
android:id="@+id/ApplicationMainSight"
android:layout_toLeftOf="@+id/ApplicationMainEvent"></Button>
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_width="fill_parent"
android:text="@string/sights"
android:id="@+id/ApplicationMainSight"
android:layout_toLeftOf="@+id/ApplicationMainEvent"></Button>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_weight="1"
android:layout_width="fill_parent"
android:text="@string/usergenerated"
android:id="@+id/ApplicationMainUserGenerated" />
<Button
android:layout_height="wrap_content"
style="@style/CKMainButton"
android:layout_weight="1"
android:layout_width="fill_parent"
android:text="@string/tours"
android:id="@+id/ApplicationMainTour"/>
</LinearLayout>
</LinearLayout>
看起来像这样:www.ImageBanana.net - layout2.png http://www.imagebanana.com/img/i2ni6g4/thumb/layout2.png
我怎样才能使布局看起来像上面的图像?
【问题讨论】: