我有一個包含項目列表的回收站視圖。這是它的外觀: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屬性的原因嗎?
感謝您的諮詢!我會讓你知道它是否有效。 –