title: Android: using marquee with TalkBack (Accessibility)
body: <p>I'm developing an application adapted to people with <code>visual disabilities</code>. If the device has an <code>Android API</code> greater than 14 I want to enhance <code>Talkback</code> a bit.</p>
  
  <p>I have a <code>ListView</code> filling the whole screen where each row has just one <code>TextView</code>. Since the text might be quite long, I wanted to use <code>marquee</code> and single line to scroll the text when the user clicks in it.</p>
  
  <p>I tested it <strong>without <code>Talkback</code></strong> and it works:</p>
  
  <p><img src="https://i.stack.imgur.com/VK2Xw.png" alt="Marquee works"></p>
  
  <p>So I decided to test it <strong>with Talkback active</strong>. In this case, I have two kind of problems:</p>
  
  <p>1- Some rows doesn't scroll at all.</p>
  
  <p>2- Some rows scroll, but I can't see more text than the one that is shown when the text isn't scrolled:</p>
  
  <p><img src="https://i.stack.imgur.com/YUrvq.png" alt="Marquee doesn&#39;t work"></p>
  
  <p>I don't know why some rows scroll and some doesn't, I use the same code for all of them. </p>
  
  <p>To change the background color and start the marquee I'm adding an <code>AccessibilityDelegate</code> to each row.</p>
  
  <p>This is the layout for each row:</p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" &gt;
  
      &lt;TextView
          android:id="@+id/rowTextView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_gravity="center_vertical"
          android:layout_marginLeft="10dp"
          android:layout_marginRight="10dp"
          android:ellipsize="marquee"
          android:marqueeRepeatLimit="marquee_forever"
          android:singleLine="true"
          android:textSize="18dp" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>And this is some of my adapter's code:</p>
  
  <pre><code>@Override
  public View getView(int position, View convertView, ViewGroup parent) {
  
      if(convertView == null){ // If the View is not cached
          // Inflates the Common View from XML file
          convertView = this.inflater.inflate(R.layout.list_simple_row, parent, false);
      }
  
      TextView tv = (TextView) convertView.findViewById(R.id.rowTextView);
      tv.setText( list.get(position) );
      convertView.setContentDescription( list.get(position) );
  
      addAccessibilityDelegate(tv, position); // Add delegate to the TextView to detect touches
  
      tv.setSingleLine(true);
  
      if(position == selected){
  
          // The user touched this row: Change background color to green. 
  
          convertView.setBackgroundColor(Color.GREEN);
          tv.setTextColor(Color.BLACK);
          tv.setSelected(true);
  
      }
      else{
  
          convertView.setBackgroundColor(Color.TRANSPARENT);
          tv.setTextColor(Color.WHITE);
          tv.setSelected(false);
  
      }
  
      return convertView;
  }
  
  protected void addAccessibilityDelegate( View v, final int position ){
  
      v.setAccessibilityDelegate(new AccessibilityDelegate(){
          @Override
          public void onInitializeAccessibilityEvent(View host, AccessibilityEvent event) {
              super.onInitializeAccessibilityEvent(host, event);
          }
  
          @Override
          public void onInitializeAccessibilityNodeInfo(View host,
                  AccessibilityNodeInfo info) {
              super.onInitializeAccessibilityNodeInfo(host, info);
          }
  
          @Override
          public void onPopulateAccessibilityEvent(View host, AccessibilityEvent event) {
              super.onPopulateAccessibilityEvent(host, event);
  
              if(event.getEventType() == AccessibilityEvent.TYPE_VIEW_HOVER_ENTER){
                  focusBackground(position);
              }
          }
      });     
  }
  
  public void focusBackground(int position){
  
      if(selected != position){
          selected = position;
          notifyDataSetInvalidated();
      }
  }
  </code></pre>
  
  <p>Anybody knows if I can use marquee with Talkback?</p>
  
  <p>Thank you!</p>