From Android API Level 17+ it supports RTL natively. To force your entire layout to be RTL including the ActionBar do the following.
Edit your AndroidManifest.xml and add android:supportsRtl="true"
to your <application>
tag and then add the following line to the top of your Activities' onCreate() method forceRTLIfSupported();
and then insert the follow function into your Activity.
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void forceRTLIfSupported()
{
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1){
getWindow().getDecorView().setLayoutDirection(View.LAYOUT_DIRECTION_RTL);
}
}
Of course that's only helpful for debugging. Use View.LAYOUT_DIRECTION_LOCALE
for production builds so your layout is only changed when the user chosen system location/language aka locale supports RTL.
Hope that helps.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…