作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 ConstraintLayout
,其中包含一个 TextView
,文本末尾有一个小图像。我遇到的这个问题是长文本没有换行。如果我修复 TextView
上的约束,以便长文本在末尾包裹图像到达屏幕末尾:
屏幕截图:
如果我将 app:layout_constraintEnd_toEndOf="parent"
添加到 TextView
,长文本会换行,但末尾的图像不会换行:
代码:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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="wrap_content"
android:padding="10dp"
android:layout_marginBottom="20dp"
android:orientation="horizontal">
<ImageView
android:id="@+id/subscription_row_item_thumb"
android:layout_width="65dp"
android:layout_height="65dp"
android:scaleType="centerInside"
android:background="@drawable/all_circle_white_bg"
android:padding="1dp"
android:foreground="?android:attr/selectableItemBackground"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
<ImageView
android:id="@+id/subscription_row_item_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:foreground="?android:attr/selectableItemBackground"
android:layout_marginTop="15dp"
app:layout_constraintTop_toBottomOf="@id/subscription_row_item_thumb"
app:layout_constraintStart_toStartOf="@id/subscription_row_item_thumb"
app:layout_constraintEnd_toEndOf="@id/subscription_row_item_thumb"/>
<TextView
android:id="@+id/subscription_row_item_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:breakStrategy="simple"
android:layout_marginStart="15dp"
android:textSize="16sp"
app:layout_constrainedWidth="true"
app:drawableEndCompat="@drawable/ic_action_open_episode_list"
android:drawablePadding="10dp"
app:layout_constraintTop_toTopOf="@id/subscription_row_item_thumb"
app:layout_constraintBottom_toBottomOf="@id/subscription_row_item_thumb"
app:layout_constraintStart_toEndOf="@id/subscription_row_item_thumb"
app:layout_constraintEnd_toEndOf="parent"/>
<TextView
android:id="@+id/subscription_row_item_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:breakStrategy="simple"
android:layout_marginTop="5dp"
android:textSize="14sp"
android:textColor="#A1A0A0"
app:layout_constraintTop_toBottomOf="@id/subscription_row_item_title"
app:layout_constraintStart_toStartOf="@id/subscription_row_item_title"/>
</androidx.constraintlayout.widget.ConstraintLayout>
最佳答案
要解决此问题,您需要:
wrap_content
保持 drawableEnd
粘在文本末尾的宽度,并避免由于 app:layout_constraintEnd_toEndOf= 而粘到末尾“ parent ”
app:layout_constraintHorizontal_bias="0"
以使 TextView
偏向开头当TextView
内容展开时,app:layout_constraintEnd_toEndOf="parent"
才会生效
将它们应用到TextView
:
<TextView
android:id="@+id/subscription_row_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:breakStrategy="simple"
android:layout_marginStart="15dp"
android:textSize="16sp"
app:layout_constrainedWidth="true"
app:layout_constraintHorizontal_bias="0"
app:drawableEndCompat="@drawable/ic_action_open_episode_list"
android:drawablePadding="10dp"
app:layout_constraintTop_toTopOf="@id/subscription_row_item_thumb"
app:layout_constraintBottom_toBottomOf="@id/subscription_row_item_thumb"
app:layout_constraintStart_toEndOf="@id/subscription_row_item_thumb"
app:layout_constraintEnd_toEndOf="parent"/>
关于android - ConstraintLayout 中带有drawableEnd 的 TextView 换行问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69316393/
在 Vaadin 7.0,显示时JavaBean Table 中的数据与 BeanContainer ,用新数据刷新表的正确方法是什么? 最佳答案 该表通过监听器监视表项的属性。如果您通过表的 Ite
首先,我使用的是带有 Axis2 1.6.2 的 eclipse,我正在 tomcat 6 上部署我创建的 Web 服务。Web 服务是在 eclipse 中通过自上而下的方法创建的。 我被要求使对我
我已将 Rails 3.1.1 应用程序升级到 Rails 3.1.3,现在,对于每个请求,它仅响应错误数量的参数(3 for 1)。不幸的是,它没有说明错误在哪里,并且应用程序跟踪为空。我认为存在一
我是一名优秀的程序员,十分优秀!