Android 在同一水平线上点亮两个按钮
我试图使“保存”和“附加图片”按钮在我的xml页面顶部对齐,但我不能完全让它工作。我把它的点,按钮将对齐只是不在同一水平线。哦,有没有办法让两个按钮在左上角和右上角对齐? 以下是xml页面:Android 在同一水平线上点亮两个按钮,android,android-layout,android-button,Android,Android Layout,Android Button,我试图使“保存”和“附加图片”按钮在我的xml页面顶部对齐,但我不能完全让它工作。我把它的点,按钮将对齐只是不在同一水平线。哦,有没有办法让两个按钮在左上角和右上角对齐? 以下是xml页面: <?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<!-- Footer Start -->
<LinearLayout
android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:layout_alignParentBottom="true"
android:background="@layout/footer_repeat"
android:orientation="horizontal" >
</LinearLayout>
<!-- Footer Ends -->
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dip" >
<!-- Save button -->
<Button
android:id="@+id/btnSavePic"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
android:text="@string/savePic"
android:layout_gravity="top|left"/>
<Button
android:id="@+id/btnAttachPic"
style="?android:attr/buttonStyleSmall"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="10dip"
android:text="@string/attachPic"
android:layout_gravity="top|right"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
新增图片:
我建议使用折叠式线性布局:
<LinearLayout
android:id="@+id/linear_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/btnSavePic"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/savePic"
/>
<Button
android:id="@+id/btnAttachPic"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="@string/attachPic"
/>
</LinearLayout>
试试这个。希望它能起作用。 将方向更改为水平方向 这样就可以使按钮水平对齐 请投票,如果它得到工作