如图,请问各位如何实现这种布局:view跟在textview的右边,view宽度固定,textview自适应宽度,但textview 加view宽度刚好到达父view宽度时,如果textview内容还没显示完应该显示省略号;就是textview宽度自适应到一定宽度后就不能再增长了。
3条回答 默认 最新
- 梦天2015 2019-06-29 17:23关注
<android.support.constraint.ConstraintLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <TextView android:id="@+id/tvs" android:layout_width="wrap_content" android:layout_height="wrap_content" android:ellipsize="end" android:maxLines="1" android:textSize="24sp" app:layout_constrainedWidth="true" app:layout_constraintEnd_toStartOf="@+id/view" app:layout_constraintHorizontal_bias="0" app:layout_constraintHorizontal_chainStyle="packed" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" android:text="我是内容我是内容" /> <View android:id="@+id/view" android:layout_width="80dp" android:layout_height="30dp" android:background="#f00" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintTop_toTopOf="parent" app:layout_constraintStart_toEndOf="@+id/tvs" /> </android.support.constraint.ConstraintLayout>
ConstraintLayout使用说明见:
https://www.jianshu.com/p/17ec9bd6ca8a本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
- ¥15 C# datagridview 单元格显示进度及值
- ¥15 thinkphp6配合social login单点登录问题
- ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
- ¥15 如何在scanpy上做差异基因和通路富集?
- ¥20 关于#硬件工程#的问题,请各位专家解答!
- ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
- ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
- ¥30 截图中的mathematics程序转换成matlab
- ¥15 动力学代码报错,维度不匹配