5

工作,正如你所知道的矢量可绘制在Android的支持库23.2这Android Developer Blog宣布,Android的所有版本,我们可以用它代替在不同添加额外的添加图标大小。 但是“启用自动镜像RTL布局”选项不会在Android的版本低于6.0的工作!有没有其他设置可以在其他Android版本中使用它?自动镜像RTL布局不中的Android版本低于6.0

enter image description here

我的测试项目使用一个简单的方法来改变我的应用程序的语言环境。 这是我的测试结果:

的Nexus 6P搭配Android 6.0,其工作良好:

enter image description here enter image description here

的Nexus 7与Android 5.0:

enter image description here enter image description here

谢谢

+0

任何答案吗? –

+0

@mostafahashim遗憾的是,似乎这个功能不会在Android版本支持低于6.0。我使用的每个图标'mipmap'和'纹理贴图,ldrtl'文件夹不同的'mipmap'必须遵循本地。对于其他图标,我使用'VectorDrawable'。 – Nava

回答

0

错误中报告:link

翻转矢量绘制如果地方是阿拉伯语和绘制是自动镜像

public static Drawable getDrawableLocale(Activity activity, @DrawableRes int drawableResId) { 
     if (!Util.isRTL() || !ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_back_white, null).isAutoMirrored()) 
      return ResourcesCompat.getDrawable(activity.getResources(), R.drawable.ic_back_white, null); 
     /** 
     * Flip it for RTl because Kitkat doesn't flip 
     */ 
     Bitmap bitmap = Util.getBitmapFromVectorDrawable(activity, drawableResId); 
     Matrix matrix = new Matrix(); 
     matrix.preScale(-1.0f, 1.0f); 
     bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); 
     return new BitmapDrawable(activity.getResources(), bitmap); 
    } 

public static Bitmap getBitmapFromVectorDrawable(Context context, int drawableId) { 
    Drawable drawable = getVectorDrawable(context, drawableId); 
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { 
     drawable = (DrawableCompat.wrap(drawable)).mutate(); 
    } 

    Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(), 
      drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888); 
    Canvas canvas = new Canvas(bitmap); 
    drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); 
    drawable.draw(canvas); 

    return bitmap; 
} 
public static Drawable getVectorDrawable(Context context, @DrawableRes int idVectorDrawable) { 
     return AppCompatDrawableManager.get().getDrawable(context, idVectorDrawable); 
    } 


public static boolean isRTL() { 
     return isRTL(Locale.getDefault()); 
    } 
public static boolean isRTL(Locale locale) { 
    final int directionality = Character.getDirectionality(locale.getDisplayName().charAt(0)); 
    return directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT || 
      directionality == Character.DIRECTIONALITY_RIGHT_TO_LEFT_ARABIC; 
} 
0

您可以使用创建自定义的ImageView如果波斯旋转180