android - 约束布局包装文本视图,但约束宽度太长而无法让其他视图可见
问题描述
我必须设计这个布局。图标应该粘在textview
.
这是我尝试过的,看起来正是需要的。
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="@dimen/padding_m"
android:paddingTop="@dimen/padding_s"
android:paddingEnd="@dimen/padding_m"
android:paddingBottom="@dimen/padding_s"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="@+id/title_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/more_options"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:id="@+id/active_group_name"
style="@style/AppbarTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:maxLines="1"
app:layout_constrainedWidth="true"
tools:text="Ranjan Malav" />
<FrameLayout
android:id="@+id/account_option_icon_container"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_gravity="center"
android:layout_marginStart="@dimen/margin_xs"
android:background="@drawable/circle_background_36dp">
<ImageView
android:id="@+id/account_option_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:srcCompat="@drawable/ic_outline_settings_24" />
</FrameLayout>
</LinearLayout>
<ImageView
android:id="@+id/more_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_baseline_more_vert_24"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
我怎样才能给图标优先级并让它占据空间,然后 textview 应该将自己包裹在剩余的空间中?
解决方案
在 textview 之前创建你的 ImageView
推荐阅读
- javascript - React - 在模糊事件中隐藏父母的子元素
- go - 如何在 SWIG 生成的 Go 包装器中添加导入语句
- python - 如何处理熊猫数据框中的缺失数据?
- settings - CLion 方法签名没有提示
- java - 使用 BulkWrite (DeleteManyModel) 删除 100 万条记录需要更长的时间
- math - 如何识别右手和左手手势张量流
- javascript - 如何使用可移动文本和徽标更新threejs纹理
- react-native - 从对象 React Native 中获取特定属性
- reactjs - 在反应中更新对象状态的正确方法(合并状态?传播运算符?)
- python - 使用 BayesSearchCV 时如何提取最佳特征?