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