2016-08-26 23 views
1

我正在努力使现有的Android应用程序可访问,并且发现它非常令人沮丧,许多事情本该工作。Android辅助功能 - 使用ImageView进行内容分组无法正常工作

我想组一起为刚刚在Google Codelabs example喜欢说明中的内容,但仍使手势导航栏中的内容可成为焦点的一部分:

我有一个LinearLayout一个Fragment与垂直方向为根查看三个RelativeLayouts,其中每个包含一个ImageView和一个TextView

layout

就像在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网页视图)并装载ImageViewPicasso

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

enter image description here

有没有人有一个想法,为什么重点跳转到TextView而不是下一个RelativeLayout

我曾尝试以下:

  • 设置ContentDescription为RelativeLayouts在XML
  • 设置ContentDescription为TextViews为null(可能不太好)
  • 改变顺序时设置的内容说明
  • TextViews设置为可对焦:false
  • 删除了ContentDescription的RelativeLayouts,这导致导航到TextViews,而不是强调整个RelativeLayout为希望

难道是一个问题,即违背Codelabs例子,我有RelativeLayout内的ImageView,而当时只有TextViews应该全部被读出来?或者是否有什么时候通过代码动态地设置xml和其他类似ClickListener的值? 我完全无能为力。

回答

0

嘿,我有一个类似的问题!我的解决方案是将我的布局的根容器设置为可调焦(android:focusable="true")。然后奇迹般地内部可调焦容器开始正常运行。