2017-03-13 5 views
3

私はConstraintLayoutを使用しています。Android:制約レイアウト - 調整できません比率のサイズ変更後の画像ビューの表示範囲

私は16:9になりたい画像ビューを持っています。このImage Viewの下に、テキストビューを配置しようとしています。

イメージビューがなくなると、テキストビューが上に移動することが予想されます。しかし、これは起こっていない。

いくつかのいずれかは、私の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 @いいえ、タデイが正確である - これは確かにありますバグ。この例では、ビューがすべての側面で制約され、なくなると、ポイントに解決されますが、制約は引き続き尊重されます。意味、この場合、すべての制約の中心にあるはずです。現在のところ、ウィジェットはサイズをゼロに設定するだけです。これは単一制約では機能しますが、二重制約では機能しません。ベータ5は正しい動作をします。私はこれを正しく理解していれば

は、Viewgoneにした場合、それはあなたがあるとして、その後、Viewは何も(ポイント)に縮小するが、その制約がまだ尊重され、上下に拘束されています。つまり、Viewはレイアウトの中央付近の点になります。テキストビューには、ゼロスペースを占めるがレイアウトの中央にゼロスペースがあるImageViewの下部に上限が設定されています。

これは実際には役に立ちませんが、何が起こっているのか説明しています。

ImageViewgoneを作成するときに、の下部制約を削除することをお勧めします。下の制約がなければ、ImageViewはレイアウトの一番上にフロートし、TextViewを配置します。

関連する問題