나는 android studio를 사용하여 프로젝트를하고 있습니다. android studio에서 layout width
을 matchparent
으로 수정하면 자동으로 368dp
으로 변경됩니다. layoutwidth
이 matchparent
으로 필요하지만 기본적으로 변경됩니다.android studio에서 레이아웃 너비가 왜 자동으로 368dp로 변경됩니까?
왜?
친절하게이 문제를 해결할 수 있도록 도와주세요.
나는 android studio를 사용하여 프로젝트를하고 있습니다. android studio에서 layout width
을 matchparent
으로 수정하면 자동으로 368dp
으로 변경됩니다. layoutwidth
이 matchparent
으로 필요하지만 기본적으로 변경됩니다.android studio에서 레이아웃 너비가 왜 자동으로 368dp로 변경됩니까?
왜?
친절하게이 문제를 해결할 수 있도록 도와주세요.
아마 부모 중 하나가 ConstraintLayout이기 때문입니다.
https://developer.android.com/training/constraint-layout/index.html
당신은 제약 단지 FrameLayout이 또는 유사한으로 ConstraintLayout 교체를 처리하지 않으려면
.나는 동일한 문제가 있었고 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>
것은 "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"
/>
layoutwidth
의 속성은 matchparent