2016-07-09 20 views
0

私は3つのボタンを水平に置こうとしています。私はグリッドを使用してアプローチし、私はサムスンギャラクシー4でそれらを正しく見ることができたが、私は小さな画面でボタンを画面に収まらない、最後のボタンがカットされてテストします。GridLayoutボタンを画面に合わせる

<GridLayout 
    android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:rowCount="1" 
     android:columnCount="3" 
     android:paddingBottom="12dp"> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/buttonCancelPost" 
      android:layout_width="96dp" 
      android:layout_row="0" 
      android:layout_column="0" 
      android:background="@color/primary" 
      android:textColor="@color/white" 
      android:layout_marginLeft="6dp" 
      android:layout_marginRight="6dp" 
      android:layout_marginEnd="6dp" 
      android:text="@string/Cancel"/> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/buttonResetPost" 
      android:layout_width="96dp" 
      android:layout_row="0" 
      android:layout_column="1" 
      android:background="@color/primary" 
      android:textColor="@color/white" 
      android:layout_marginRight="6dp" 
      android:layout_marginEnd="6dp" 
      android:text="@string/Reset"/> 

     <android.support.v7.widget.AppCompatButton 
      android:id="@+id/buttonSubmitPost" 
      android:layout_width="96dp" 
      android:layout_row="0" 
      android:layout_column="2" 
      android:background="@color/primary" 
      android:textColor="@color/white" 
      android:text="@string/post"/> 
    </GridLayout> 

答えて

0

3つのボタンの幅の合計が画面の幅を超えているため、最後のものはカットされません。layout_widthボタンがすべて収まるまで減らしてください。

ボタンのテキストプロパティは、ボタンのサイズにも考慮する必要があります。

+0

ハードコードされた値を避けようとしています。 – hotspring

関連する問題