工具栏

时间:2016-02-24 07:03:57

标签: android android-actionbar android-toolbar

我需要在我的应用程序上支持RTL语言,问题是某些设备上的后退箭头,特别是三星galaxy note 4.目前为止在其他设备上没有问题,但是在注4中。 如何更改此设备的方向? 这是我的方式:

清单上的

android:supportsRtl="true"

图书馆: 我正在使用 appcompatV7(最新版本)

drawable文件夹: 我添加了支持库版本4中的所有文件夹,如drawable-ldrtl-xxxhdpi

绘制: 我在每个可绘制文件夹中使用android提供的abc_ic_ab_back_mtrl_am_alpha.png

代码:

    if(Build.VERSION.SDK_INT>17)
    mToolBar.setLayoutDirection(View.LAYOUT_DIRECTION_RTL);

我也添加了这个:         getSupportActionBar().setHomeAsUpIndicator(R.drawable.abc_ic_ab_back_mtrl_am_alpha);

也在我的 style.xml 中有:

    <item name="homeAsUpIndicator">@drawable/abc_ic_ab_back_mtrl_am_alpha</item>

所有这些,到目前为止所有设备上的后箭头方向都没问题,除了三星Galaxy note 4!附加图像在三星音符4上输出,这是错误的,后箭头应该指向右而不是左 有人可以帮忙吗

wrong direction! should point to right not left 问候

2 个答案:

答案 0 :(得分:1)

最后通过使用以下代码行解决了这个问题:

getSupportActionBar().setHomeAsUpIndicator(R.drawable.back_arrow)

答案 1 :(得分:0)

右键单击drawable&gt; New&gt; Image Asset&gt;图标类型:Action Bar&amp;标签图标...为您想要的颜色。 并将其添加到您的风格

 <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
     <!--... Your Style...-->
     <item name="android:homeAsUpIndicator">@drawable/ic_action_back</item>
 </style>

Just right click drawable>New>Image Asset> Icon Type: Action Bar & Tab Icons...

相关问题