我想使2按钮占据屏幕宽度的一半,但是我真的只有一个按钮来到屏幕上,并采取全屏幕宽度。我想要所有的分辨率,所以不想修改宽度。一个按钮将左半等将右半这可怎么办android简单布局
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="left" />
<Button
android:id="@+id/button2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Button"
android:layout_gravity="right" />
</LinearLayout>
</ScrollView>
此问题已在stackoverflow上被询问了几次 - 一个示例:http://stackoverflow.com/questions/11286147/android-setting-button-width-half-the-screen/11286169#11286169 - 如果您使用你会发现更多的搜索 –