我想使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 - 如果您使用你會發現更多的搜索 –