2017-05-18 4 views

답변

2

나는 동일한 문제가 있었고 ConstraintLayout을 사용했습니다. 여기에 내가 부모로 설정 내가 안드로이드 스튜디오 내 폭을 재 작성을 중지하기로해야 할 일을했을 모든

<android.support.constraint.ConstraintLayout 
    android:id="@+id/activity_content" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <!--header row--> 
    <include 
     android:id="@+id/content_header" 
     layout="@layout/adapter_fish_row_header" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     android:layout_marginLeft="4dp" 
     android:layout_marginTop="8dp" 
     android:layout_marginStart="4dp" 
     android:layout_marginRight="4dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" /> 

    <!-- The main content view --> 
    <android.support.v7.widget.RecyclerView 
     android:id="@+id/fish_list" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:scrollbars="vertical" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintTop_toBottomOf="@+id/content_header" 
     android:layout_marginLeft="4dp" 
     android:layout_marginTop="8dp" 
     android:layout_marginStart="4dp" 
     android:layout_marginRight="4dp" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintHorizontal_bias="0.0" /> 

    <Button 
     android:id="@+id/form_submit_button" 
     style="@style/form_submit_btn" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginEnd="4dp" 
     android:layout_marginLeft="4dp" 
     android:layout_marginRight="4dp" 
     android:layout_marginStart="4dp" 
     android:background="@color/primary" 
     android:text="@string/btn_next_page" 
     android:textColor="@color/text_primary" 
     app:layout_constraintHorizontal_bias="0.496" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     android:layout_marginTop="8dp" 
     app:layout_constraintTop_toBottomOf="@+id/fish_list" /> 


</android.support.constraint.ConstraintLayout> 
0

것은 "0dp"와 "match_parent"를 교체하고 제약 조건을 추가 app:layout_constraintRight_toRightOf="parent"가 내 경우에는 뭔가 설정되어 있는지 확인하는 것이 었습니다 ConstraintLayout에. 예를 들어

, 부모 일치 바닥, 높이 50 픽셀 및 폭에 부착 된 버튼 :

<Button 
    android:layout_width="0dp" 
    android:layout_height="50dp" 
    android:background="@color/azzurro" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    app:layout_constraintBottom_toBottomOf="parent" 
    android:text="MY BUTTON" 
/> 
0
  1. 이동하여 XML을 디자인보기로
  2. 끌어 변경 수동
  3. 을 뷰를 대체하여 layoutwidth의 속성은 matchparent