2017-05-18 19 views
3

私はアンドロイドスタジオを使ってプロジェクトをやっています。アンドロイドスタジオでlayout widthmatchparentと修正すると自動的に368dpに変更されます。 layoutwidthmatchparentとして必要ですが、デフォルトで変更されています。アンドロイドスタジオで、レイアウト幅のmatchparentが自動的に368dpに変更されるのはなぜですか?

なぜですか?

親切にこの問題を解決するのを手伝ってください。

答えて

2

私は同じ問題があり、私はConstraintLayoutを使用していました。私は自分の幅を書き換えを停止するには、Androidのスタジオのためにしなければならなかったすべてはapp:layout_constraintRight_toRightOf="parent"がここで私は「0dp」と「match_parent」を交換し、制約を追加、親

<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

に設定私の場合、何かに設定されていることを確認しましたをConstraintLayoutに設定します。例えば

、親と一致する下、高さは50pxと幅に添付ボタン:

<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
関連する問題