2016-07-09 7 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 개의 너비를 합한 너비가 화면의 너비를 초과합니다. 그 이유는 마지막 너비가 cut.try가 모두 맞을 때까지 layout_width 버튼을 줄이는 것입니다. 괜찮 으면 수직 배열을 시도하십시오.

단추 텍스트 속성은 단추 크기에 고려해야 할 항목을 추가합니다.

+0

하드 코딩 된 값을 피하려고합니다. – hotspring

관련 문제