私はAndroidスタジオ2.2にアップデートして、新しいUIビルダーでConstraintLayout
を使用し始めているので、解決できない問題があります。ConstraintLayoutとTextViewの問題wrap_content
ImageView
の右側にImageView
とTextView
という単純なレイアウトがあります。 TextView
のテキストは、サーバーから動的に更新されます(このテキストの正確な長さはわかりません)。 TextView
は、ImageView
と画面の右側の間のすべての空きスペースを使用します。以前RelativeLayout
と私はTextView
android:layout_width="wrap_content"
を使用し、それが働いた:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="116dp"
android:layout_height="178dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
tools:src="@drawable/pets"/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/imageView"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_toEndOf="@+id/imageView"
android:layout_toRightOf="@+id/imageView"
tools:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque molestie tincidunt mi a gravida. Aenean faucibus a sapien ut consequat. Praesent sed placerat quam."/>
</RelativeLayout>
をしかし、私はConstraintLayoutを使用するとき、そこにはtextwrapされていないとのTextViewが画面の外に起こっています。
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imageView"
android:layout_width="116dp"
android:layout_height="178dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/pets"/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:ellipsize="none"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque molestie tincidunt mi a gravida. Aenean faucibus a sapien ut consequat. Praesent sed placerat quam."
app:layout_constraintLeft_toRightOf="@+id/imageView"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
を確認することができ、RelativeLayoutと一緒にConstraintLayoutを使用しないでください!できます!ありがとう! – rbaloo
それは働いていません。 alpha 9&ConstraintLayout 1.0.2をインストールしましたが、動作しません。コンテンツが画面外に出る – Amit