2017-04-19 18 views
5
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:fillViewport="true"> 

    <android.support.constraint.ConstraintLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"> 

///Content 

    </android.support.constraint.ConstraintLayout> 

</android.support.v4.widget.NestedScrollView> 

에 중첩되어있는 경우. 나는 또한 여백보기에 문제가있다.제약 레이아웃 조치 잘못된 높이가 긴이 경우 제약 레이아웃에있는 ScrollView

<TextView 
      android:id="@+id/tvDurationPlan" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_marginTop="@dimen/margin_medium" 
      android:textSize="@dimen/txt_size_small" 
      style="@style/WhiteTextViewStyle" 
      app:layout_constraintBottom_toBottomOf="parent" 
      app:layout_constraintHorizontal_bias="0.0" 
      app:layout_constraintLeft_toLeftOf="@+id/tvPlanLabel" 
      app:layout_constraintRight_toRightOf="parent" 
      app:layout_constraintTop_toBottomOf="@+id/tvPlanLabel" 
      app:layout_constraintVertical_bias="0.0" 
      android:layout_marginEnd="16dp" 
      tools:text="TextView" /> 

과 비슷한 많은 하위보기가 있으며 layout_marginEnd가 작동하지 않습니다. 도와주세요!

+0

어떤 버전의 Constraint Layout을 사용하고 있습니까? 최신 버전으로 업데이트하셨습니까? – ianhanniballake

+0

예, 1.0.2를 사용합니다. –

+0

안녕하세요 @horkucherenko, 높이 문제에 대한 해결책을 찾았습니까? Scrollview 내부에서 ConstraintLayout (v1.0.2)과 동일한 문제가 발생하고 스크롤 할 수있는 CL 아래에 큰 빈 공간이 생깁니다. ScrollView가 제거되면 사라집니다. –

답변

0

우리가 안드로이드 사용할 필요가 marginEnd으로 문제를 해결하려면 아이가

0

내가 마지막으로 뷰의 위치를 ​​얻을이 문제를 해결하고 제약 레이아웃의 높이로이 값을 설정하려면 뷰에 대한 layout_width = "0dp"를

private void adjustConstraintLayoutToView(View view) { 
    final ViewTreeObserver vto = view.getViewTreeObserver(); 
    vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { 
     @Override 
     public void onGlobalLayout() { 
      if (mConstraintLayout.getMeasuredHeight() > 0) { 
       int[] location = new int[2]; 
       view.getLocationOnScreen(location); 
       mConstraintLayout.getLayoutParams().height = location[1]; 
       mConstraintLayout.requestLayout(); 
       if (vto.isAlive()) { 
        vto.removeOnGlobalLayoutListener(this); 
       } else { 
        view.getViewTreeObserver().removeOnGlobalLayoutListener(this); 
       } 
      } 
     } 
    }); 
} 
0

이 버그는 com.android.support.constraint에서 수정되었습니다. constraint-layout : 1.1.0-beta3