title: How to get the "up" button used on the Toolbar?
body: <p>This is a short question:</p>
  
  <p>I'm trying to force the action bar (used by a Toolbar) to use LTR alignment. I've succeeded making the layout itself use LTR, but not the "up" button (as I've done <a href="https://stackoverflow.com/q/22602453/878126"><strong>here</strong></a>, before <a href="http://developer.android.com/reference/android/support/v7/widget/Toolbar.html" rel="nofollow noreferrer"><strong>Toolbar</strong></a> was introduced) .</p>
  
  <p>It seems this view doesn't have an ID, and I think using getChildAt() is too risky.</p>
  
  <p>Can anyone help?</p>
  
  <hr>
  
  <h2>The answer</h2>
  
  <p>Here's one way I've found to solve this, based on <a href="https://stackoverflow.com/a/27180584/878126"><strong>this answer</strong></a> .</p>
  
  <p>I made it so that it is guarranteed to find only the "up" button, and whatever it does, it will revert back to the previous state it was before.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>  @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
    @Override
    public boolean onCreateOptionsMenu(final Menu menu)
      {
      // &lt;= do the normal stuff of action bar menu preparetions
      if(VERSION.SDK_INT&gt;=VERSION_CODES.JELLY_BEAN_MR1&amp;&amp;getResources().getConfiguration().getLayoutDirection()==View.LAYOUT_DIRECTION_RTL)
        {
        final ArrayList&lt;View&gt; outViews=new ArrayList&lt;&gt;();
        final CharSequence previousDesc=_toolbar.getNavigationContentDescription();
        for(int id=0;;++id)
          {
          final String uniqueContentDescription=Integer.toString(id);
          _toolbar.findViewsWithText(outViews,uniqueContentDescription,View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
          if(!outViews.isEmpty())
            continue;
          _toolbar.setNavigationContentDescription(uniqueContentDescription);
          _toolbar.findViewsWithText(outViews,uniqueContentDescription,View.FIND_VIEWS_WITH_CONTENT_DESCRIPTION);
          if (outViews.isEmpty())
             if (BuildConfig.DEBUG)
                      throw new RuntimeException(
                              "You should call this function only when the toolbar already has views");
                  else
                      break;
          outViews.get(0).setRotation(180f);
          break;
          }
        _toolbar.setNavigationContentDescription(previousDesc);
        }
      //
      return super.onCreateOptionsMenu(menu);
      }
  </code></pre>