我正在努力使现有的Android应用程序可访问,并且发现它非常令人沮丧,许多事情本该工作。Android辅助功能 - 使用ImageView进行内容分组无法正常工作
我想组一起为刚刚在Google Codelabs example喜欢说明中的内容,但仍使手势导航栏中的内容可成为焦点的一部分:
我有一个LinearLayout
一个Fragment
与垂直方向为根查看三个RelativeLayouts
,其中每个包含一个ImageView
和一个TextView
。
就像在codelabs,我已经设置了RelativeLayout
到可获得焦点,为ImageViews
我已经设置了ContentDescription
为null,因为它们是纯粹的装饰。
这是XML
布局这些RelativeLayouts
与根LinearLayout
之一:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/white"
android:orientation="vertical"
tools:context="com.my.fancyapp.fragments.OtherFragment">
<RelativeLayout
android:id="@+id/item_youtube"
android:layout_width="match_parent"
android:layout_height="@dimen/other_item_height"
android:focusable="true"
android:background="?attr/selectableItemBackground"
android:padding="@dimen/other_item_padding">
<ImageView
android:id="@+id/ivYouTube"
android:layout_width="@dimen/other_icon_width"
android:contentDescription="@null"
android:layout_height="match_parent"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/other_text_margin_left"
android:text="YouTube"
android:textAppearance="@style/ArtistTextAppearance" />
</RelativeLayout>
...
</LinearLayout>
在Fragment
,我设置一个onClickListener
每个RelativeLayout
,其链接到立体图(YouTube频道,Facebook页面或与IMPRESSUM网页视图)并装载ImageView
与Picasso
:
itemYoutube.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(youTubeUrl));
startActivity(intent);
}
}
});
Picasso.with(getActivity())
.load(R.drawable.icon_youtube)
.fit()
.centerInside()
.into(iconYoutube);
itemYoutube.setContentDescription(getString(R.string.youtube));
现在proble M是想点击一个项目,然后通过滑动到下一个项目导航导致文本中强调,不通过导航到下一个RelativeLayout
有没有人有一个想法,为什么重点跳转到TextView
而不是下一个RelativeLayout
?
我曾尝试以下:
- 设置ContentDescription为
RelativeLayouts
在XML - 设置ContentDescription为
TextViews
为null(可能不太好) - 改变顺序时设置的内容说明
- 将
TextViews
设置为可对焦:false - 删除了ContentDescription的
RelativeLayouts
,这导致导航到TextViews
,而不是强调整个RelativeLayout
为希望
难道是一个问题,即违背Codelabs例子,我有RelativeLayout
内的ImageView
,而当时只有TextViews
应该全部被读出来?或者是否有什么时候通过代码动态地设置xml和其他类似ClickListener
的值? 我完全无能为力。