1

「保存」ボタンと「写真を添付」ボタンをxmlページの上部に配置しようとしていますが、うまく機能しません。ボタンが同じ水平線ではなく整列するようになりました。ああ、両方のボタンを左上隅と右上隅に揃える方法はありますか? xml ページは次のとおりです。

<?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>

画像を追加: http://tinypic.com/view.php?pic=4ihut4&s=5#.Uj9eHBbnZAh

4

2 に答える 2

4

eclothing LinearLayout を使用することをお勧めします。

<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>
于 2013-09-22T21:22:56.407 に答える
-1

これを試して。それがうまくいくことを願っています。ボタンを水平方向に配置できるように、方向を水平に変更します。

それがうまくいくかどうか投票してください。

于 2013-09-24T07:42:04.573 に答える