我想以这种方式用按钮填充布局:
我尝试了一个表格布局,但我无法在按钮之间获得正确的空间,当我尝试不同的屏幕尺寸时,一切都搞砸了(即使我使用的是android:layout_weight)所以现在我正在尝试相对布局,但我不能让屏幕改变时按钮采取正确的大小,我已经阅读有关处理不同屏幕尺寸的提示,所以我使用dp和wrap_content,但没有任何作用,这是我的代码:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="24dp"
android:layout_marginTop="31dp"
android:layout_marginRight="150dp"
android:background="@layout/press"
android:drawableTop="@drawable/reading"
android:text="@string/option" />
<Button
android:id="@+id/Button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="@+id/button1"
android:layout_alignBottom="@+id/button1"
android:layout_alignParentRight="true"
android:layout_marginRight="28dp"
android:layout_alignParentLeft="true"
android:layout_marginLeft="150dp"
android:background="@layout/press"
android:drawableTop="@drawable/reading"
android:text="@string/option" />
</RelativeLayout>
我要设置第一行按钮,但Button2不应该调整大小,我做错了什么?或者我怎么能做到这一点? 谢谢。
答案 0 :(得分:0)
试试这个。
<LinearLayout
android:orientation = "vertical">
<LinearLayout
android:orientation = "horizontal"/>
2 Buttons here.
</LinearLayout>
</LinearLayout>
不要忘记包括线性布局的高度和宽度。希望这会有所帮助。