ConstraintLayoutの中のTextViewが欠ける
ConstraintLayoutの中に複数行のTextViewを置いた時、ConstraintLayoutのレイアウトに合わせて折返しされず行末が表示されない問題。 以下の記事と同じ現象で参考にさせてもらいました。
https://stackoverflow.com/questions/46350501/android-constraintlayout-textview-go-off-the-screen https://qiita.com/henteko/items/f5cf5d550aca9a182ab8
解決策はapp:layout_constraintEnd_toEndOf="parent"
を親のConstraintLayoutにつけることと、layout_width
を0dp
にするとうまく表示された。
before
<android.support.constraint.ConstraintLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/imageView" app:layout_constraintTop_toTopOf="parent">
after
<android.support.constraint.ConstraintLayout android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="16dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toEndOf="@id/imageView" app:layout_constraintTop_toTopOf="parent">
環境 ConstraintLayout version => 1.0.2 AndroidStudio => 3.1
[追記 10.30]
v1.1からwrap_contentで制約を効くようにapp:layout_constrainedWidth="true|false"
が使えるそうなのでこっちを使うほうがいいのかも。