android - ConstraintLayout中的右文本视图,文本被切断
问题描述
我在 android 中使用 ConstraintLayout 布局。我希望我的图像在左侧,我的文本在图像的右侧。
<?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/galleryImg"
android:layout_width="150dp"
android:layout_height="150dp"
android:onClick="toggleMode"
android:layout_marginLeft="10dp"
android:scaleType="centerCrop"
android:src="@drawable/slider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="parent"
/>
<TextView
android:id="@+id/galTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Quick Brown Fox Jumps Over Quick Brown Fox Jumps Over"
android:textSize="18sp"
android:layout_alignParentRight="true"
app:layout_constraintStart_toEndOf="@+id/galleryImg"
app:layout_constraintTop_toTopOf="@+id/galleryImg" />
</android.support.constraint.ConstraintLayout>
但是我的文本在右侧被切断 - 就像我的文本在第一行结束时.. 它只显示ov并且下一行以Quick开头。
解决方案
在这里,这应该工作:
<?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/galleryImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:contentDescription="TODO"
android:src="@drawable/slider"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<TextView
android:id="@+id/galTitle"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:text="Quick Brown Fox Jumps Over Quick Brown Fox Jumps Over"
app:layout_constraintBottom_toBottomOf="@+id/galleryImg"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/galleryImg"
app:layout_constraintTop_toTopOf="@+id/galleryImg"/>
</android.support.constraint.ConstraintLayout>
推荐阅读
- python - 了解python字典的顺序
- java - 压缩解压字符串得到的数据与原始压缩数据不一致
- python - 获取 Twisted 服务器的 IP 地址
- node.js - 如何在 AWS EC2 中为多个开发人员正确安装 nvm/node/npm?
- python - MySQL 数据为 varchar 255 和字符串截断
- python - BulkIndexError: ('500 document(s) failed to index.',使用 Python + Elastic Searc
- javascript - React Native Undefined 不是一个对象(评估'userData.id)
- r - 如何制作数据框的三个月平均值并使用这些值构建新的数据框?
- c# - C# .NET 多线程访问 MS Excel 文件
- kubernetes - 应用基岩 terraform 后获取 kuberbenetes 地址的 aks publicIP/loadbalancer IP