2017-03-13 8 views
3

ConstraintLayout을 사용하고 있습니다.안드로이드 : 제약 레이아웃 - 조절할 수 없습니다 비율 크기 조정 후 이미지보기의 경계를 봅니다

저는 16시 9 분이되고 싶은 이미지가 있습니다. 그리고이 이미지 뷰 아래에서 텍스트 뷰를 배치하려고합니다.

이제 이미지보기를 사라지도록 설정하면 텍스트보기가 위로 이동해야합니다. 그러나 이것은 일어나지 않습니다.

어떤 사람은 내 XML 레이아웃에서 문제를 파악하는 것을 시도하십시오 수 :

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
    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:background="@color/dark_background" 
    android:layout_width="0dp" 
    android:layout_height="0dp" 
    android:padding="15dp" 
    tools:layout_width="300dp" 
    tools:layout_height="300dp" 
    > 

    <ImageView 
     android:id="@+id/image" 
     android:layout_width="wrap_content" 
     android:layout_height="0dp" 
     android:adjustViewBounds="true" 
     android:scaleType="centerInside" 
     android:src="@drawable/logo" 
     app:layout_constraintDimensionRatio="W,16:9" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintBottom_toBottomOf="parent" 
     app:layout_constraintTop_toTopOf="parent" 
     app:layout_constraintHorizontal_bias="0.5" 
     app:layout_constraintVertical_bias="1.0" /> 

    <TextView 
     android:id="@+id/title" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     app:layout_constraintLeft_toLeftOf="parent" 
     app:layout_constraintRight_toRightOf="parent" 
     app:layout_constraintTop_toBottomOf="@id/image" 
     android:ellipsize="marquee" 
     android:maxLines="4" 
     android:textSize="28sp" 
     android:textColor="#000000" 
     android:text="The is the test that does not seem to work" 
     android:layout_marginTop="12.41dp" 
     app:layout_goneMarginTop="0dp"/> 


</android.support.constraint.ConstraintLayout> 
+0

누구든지주세요 ?? – Sunny

답변

0

난 당신이보고있는 행동이 ConstraintLayout으로 설계된 것입니다 생각합니다. 그것은 gone보기 어떤 공간을 차지하는 것해야 카운터 직관적 인 것 같다,하지만 이슈 트래커에 this issue에서 코멘트 # 8이 문으로 구성됩니다

@ 아니, 타데가 올바른지 herrbert74 -이 참 버그. 보기가 모든면에서 제약을 받고 사라지게되는이 예제에서는 한 지점으로 해결해야하지만 제약 조건은 여전히 ​​존중되어야합니다. 의미,이 경우 그것은 모든 제약의 중심에 있어야합니다. 현재 위젯은 크기를 0으로 설정합니다. 이는 단일 제한 조건에서 작동하지만 이중 제한 조건에서는 작동하지 않습니다. 베타 5는 올바른 동작을합니다. 나는이 상황을 제대로 이해한다면

Viewgone을 만들 때 그것은 당신이 한, 다음 View 아무것도 (포인트)로 축소하지만 제약이 여전히 존중, 상단과 하단에 제한됩니다. 즉, View은 레이아웃의 중심에 가까운 지점이됩니다. 텍스트보기에는 0 공간을 차지하지만 레이아웃 중간에 공간이없는 ImageView 맨 아래에 상위 제한 조건이 있습니다.

이렇게 도움이되지는 않지만, 무슨 일이 일어나는지 설명합니다.

ImageViewgone을 만들 때 수행 할 작업의 한 가지 방법은 ImageView의 아래쪽 제약 조건을 제거하는 것입니다. 하단 구속 조건이 없으면 ImageView이 레이아웃 상단으로 이동하여 TextView을 가져옵니다.