2017-01-02 19 views
0

1行目に3つのイメージボタンがあり、2行目に3つのイメージボタンがあります。 相対レイアウトと線型レイアウトの組み合わせで実装しようとしましたが、どういうわけか、各行に1つのイメージボタンと合計6行で終了しています。イメージボタンを相対レイアウトと線形レイアウトの中に配置することができません

誰かが第1行の3つのイメージボックスと第2行の3つのボックスを整列させる手助けをしてくれますか?

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context="app.com.date.design.drawer.AddImagesFragment"> 

    <!-- TODO: Update blank fragment layout --> 

    <RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/layout1" 
      android:baselineAligned="false" 
      android:orientation="vertical"> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image1" /> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image2" /> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image3" /> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image4" /> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image5" /> 

      <ImageButton 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       app:srcCompat="@drawable/common_full_open_on_phone" 
       android:id="@+id/image6" 
       android:layout_weight="0.05" /> 
     </LinearLayout> 

    </RelativeLayout> 

</FrameLayout> 

答えて

1

activity_main.xml、このコードを試してみてください。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin"> 

    <LinearLayout 
     android:id="@+id/lin1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:weightSum="3"> 

     <ImageButton 
      android:id="@+id/image1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star2" /> 

     <ImageButton 
      android:id="@+id/image2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star1" /> 

     <ImageButton 
      android:id="@+id/image3" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star3" /> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/lin2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/lin1" 
     android:orientation="horizontal" 
     android:weightSum="3"> 

     <ImageButton 
      android:id="@+id/image4" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star2" /> 

     <ImageButton 
      android:id="@+id/image5" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star1" /> 

     <ImageButton 
      android:id="@+id/image6" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      app:srcCompat="@drawable/star3" /> 

    </LinearLayout> 


</RelativeLayout> 

これによって、私はスクリーンショット、

enter image description here

を取り付けるMが、それはあなたを助けることを願っています。

+0

ありがとうございました。 – user7327850

+0

welcome :) :) :) :) –

関連する問題