我有一个包含项目列表的回收站视图。这是它的外观:AccessibilityTraversalBefore不适用于对讲
我需要补充对讲支持。问题在于回收商物品视图内的重点排序。
这应该正确的顺序:
1. Name of first member (A)
2. Amount under first member's name (2469...)
3. Name of second member (B)
4. Amount under second member's name (2469...)
的问题是,默认的焦点顺序是不同的:
1) Name of the first member
2) Name of the second member
3) Amount under the first member
4) Amount under the second member
的解决方案应该是很容易的。有一个参数android:accessibilityTraversalBefore =“@ + id/someID”,它改变了焦点的顺序。我在我的应用程序的其他视图中使用此参数没有问题 - 它很好。但是,当我在此处使用它时,它根本没有任何影响 - 视图仍以默认顺序为重点。 让我们来看看回收项目布局:
<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="56dp">
<android.support.constraint.Guideline
android:id="@+id/vGuideline"
style="@style/Layout.Guideline"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.5"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/vFirstAvatar"
style="@style/Image.AvatarMember"
app:layout_constraintBottom_toBottomOf="parent"
tools:src="@drawable/avatar_multiple" />
<!-- Ellipsized because it can overlay the second member. -->
<android.support.v7.widget.AppCompatTextView
android:id="@+id/vFirstName"
style="@style/TextView.NameEllipsized"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="11dp"
android:layout_marginEnd="8dp"
android:importantForAccessibility="yes"
android:layout_marginRight="8dp"
android:accessibilityTraversalBefore="@+id/vFirstAmount"
android:textAppearance="@style/ListPrimaryTiny"
app:layout_constraintLeft_toRightOf="@+id/vFirstAvatar"
app:layout_constraintRight_toLeftOf="@+id/vGuideline"
app:layout_constraintTop_toTopOf="parent"
tools:text="Suzan" />
<!-- Ellipsized because it can overlay the second member. -->
<android.support.v7.widget.AppCompatTextView
android:id="@+id/vFirstAmount"
style="@style/TextView.NameEllipsized"
android:layout_marginTop="2dp"
android:accessibilityTraversalBefore="@+id/vSecondName"
android:textAppearance="@style/ListSecondary"
android:importantForAccessibility="yes"
app:layout_constraintLeft_toLeftOf="@+id/vFirstName"
app:layout_constraintRight_toRightOf="@id/vGuideline"
app:layout_constraintTop_toBottomOf="@+id/vFirstName"
tools:text="$22" />
<android.support.v7.widget.AppCompatImageView
android:id="@+id/vSecondAvatar"
style="@style/Image.Avatar"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:src="@drawable/avatar_multiple" />
<!-- Ellipsized because it can overlay first member. -->
<android.support.v7.widget.AppCompatTextView
android:id="@+id/vSecondName"
style="@style/TextView.NameEllipsized"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:importantForAccessibility="yes"
android:accessibilityTraversalBefore="@+id/vSecondAmount"
android:layout_marginTop="11dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:gravity="end"
android:textAppearance="@style/ListPrimaryTiny"
app:layout_constraintLeft_toLeftOf="@+id/vGuideline"
app:layout_constraintRight_toLeftOf="@+id/vSecondAvatar"
app:layout_constraintTop_toTopOf="parent"
tools:text="Dave" />
<!-- Ellipsized because it can overlay the first member. -->
<android.support.v7.widget.AppCompatTextView
android:id="@+id/vSecondAmount"
style="@style/TextView.NameEllipsized"
android:layout_marginTop="2dp"
android:importantForAccessibility="yes"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:gravity="end"
android:textAppearance="@style/ListSecondary"
app:layout_constraintRight_toRightOf="@+id/vSecondName"
app:layout_constraintLeft_toLeftOf="@id/vGuideline"
app:layout_constraintTop_toBottomOf="@+id/vSecondName"
tools:text="$8" />
</android.support.constraint.ConstraintLayout>
你有什么想法究竟是为什么对讲完全忽略 AccessibilityTraversalBefore属性的原因吗?
感谢您的咨询!我会让你知道它是否有效。 –