【发布时间】:2018-02-04 08:24:16
【问题描述】:
我在参考线上方使用this 颜色选择器,并希望在参考线下方对齐文本视图(和其他视图),并通过使用带有以下选项的 ConstraintLayout 将它们绑定到颜色选择器的宽度:
app:layout_constraintRight_toRightOf="@+id/colorPicker"
app:layout_constraintLeft_toLeftOf="@+id/colorPicker"
(颜色选择器的宽度取决于可用的高度。)
我面临的问题是视图似乎恰好位于颜色选择器下方,但是,视图的内容未调整,因此未完全显示,如this 图片所示。
使用 ImageView 而不是 TextView 可以重现类似的行为。 RecyclerView 似乎正在工作,但是,到达列表开头或结尾时的“列表结束动画”放错了位置。
当使用其他视图而不是这个颜色选择器时,我不会遇到这个问题。
谁能解释这种行为以及如何解决它?
我为此使用的完整 xml 代码:
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="xxx.xxx.xxx.MainActivity">
<com.rarepebble.colorpicker.ColorPickerView
android:id="@+id/colorPicker"
android:layout_width="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="@+id/guideline"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
/>
<android.support.constraint.Guideline
android:id="@+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintGuide_percent="0.60"
android:orientation="horizontal"
/>
<TextView
android:id="@+id/textView"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Hello World! Some chars in this TextView are cut on the right side."
app:layout_constraintTop_toTopOf="@+id/guideline"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="@+id/colorPicker"
app:layout_constraintLeft_toLeftOf="@+id/colorPicker"
/>
</android.support.constraint.ConstraintLayout>
【问题讨论】:
标签: android android-constraintlayout