在我的项目中,我有一个4按钮的视图。我有一个相对布局来正确放置它们。问题是我想让按钮填满整个屏幕而不会消失,我不想为它们设置固定大小以确保按钮适合任何屏幕大小。现在我唯一能看到的就是一个大按钮,因为RelativeLayout没有android:layout_weight
。我怎样才能做到这一点?这是我得到:按钮大小调整问题。 Android
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/search_icon"
android:background="@drawable/search_icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/categories_icon"
android:background="@drawable/categories"
android:layout_toRightOf="@+id/search_icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/green_icon"
android:background="@drawable/green_icon"
android:layout_below="@+id/search_icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<Button
android:id="@+id/red_icon"
android:background="@drawable/red_icon"
android:layout_toRightOf="@+id/green_icon"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
</RelativeLayout>
我照你说的做了,但没有奏效。我会再次发布代码 – 2011-01-28 15:48:29
试试我今天发布的代码。我这样做:http://3.ly/UXg2 – gnclmorais 2011-01-29 20:47:17