我一直在研究新的谷歌支持设计库.我正在努力使导航栏变得半透明,并在栏下方显示recyclerView的内容.
我正在测试5.1 nexus 5.我使用下面的项目作为测试项目.示例代码来自Chris Banes:https://github.com/chrisbanes/cheesesquare
我在下面添加了styles.xml
<item name="android:windowTranslucentNavigation">true</item>
Run Code Online (Sandbox Code Playgroud)
使导航栏半透明.
但是,我无法将CoordinatorLayout及其内容(recyclerView)显示在条形图下方.
我想要的是:
recyclerView显示在导航栏下
快速返回是存在的,当隐藏appbar时,它不应该在半透明状态栏下面.状态栏应该能够完全隐藏向上滚动的部分.
我有一个TextView向左对齐并垂直居中。两组ImageView和TextView均右对齐,有两种布局配置,一组右图,一组左图。
hello world 文本可能很长。我希望它扩展以填充整个宽度而不覆盖左侧文本。
我添加app:layout_constraintStart_toEndOf="@id/text1"了约束右侧组(图像+文本)不与左侧文本重叠。但是,它的行为并不像我预期的那样。
如何仅使用 ConstraintLayout 使其不重叠?
Text1如果正确的文本太长,则会被掩盖,这是意料之中的。请注意,第二行的图像也不见了。

代码:
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Text1" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/row1_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toStartOf="@id/row1_image"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/text1"
app:layout_constraintTop_toTopOf="parent"
tools:text="Hello World" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/row1_image"
android:layout_width="22dp"
android:layout_height="22dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@id/row1_text"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/ic_confirm" />
<androidx.constraintlayout.widget.Barrier
android:id="@+id/horizontal_barrier"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:barrierDirection="bottom"
app:constraint_referenced_ids="row1_text,row1_image" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/row2_image"
android:layout_width="22dp"
android:layout_height="22dp"
app:layout_constraintEnd_toStartOf="@id/row2_text"
app:layout_constraintHorizontal_bias="1"
app:layout_constraintHorizontal_chainStyle="packed"
app:layout_constraintStart_toEndOf="@id/text1"
app:layout_constraintTop_toTopOf="@id/horizontal_barrier"
tools:src="@drawable/ic_confirm" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/row2_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content" …Run Code Online (Sandbox Code Playgroud)