How to specify RTL specific drawables

后端 未结 3 601
情书的邮戳
情书的邮戳 2021-01-31 15:33

I have few images that looks different on right-to-left. Is it possible to create rtl specific drawable directory or some rtl post-fix for file names to auto-load relevant image

3条回答
  •  悲&欢浪女
    2021-01-31 16:18

    For 17+ (4.2.x+) you can use layout direction (ld) resources qualifier, for right to left (RTL) you can use ldrtl and for left to right (LTR) you can use ldltr, e.g. you can use

    res/ drawable // Default drawable-ldltr // LTR drawable-ldrtl // RTL

    Also as any other qualifier you can combine it with many others e.g. drawable-ldrtl-xhdpi, please note how ldrtl comes before xhdpi otherwise aapt will complain.

    And as @Dennis mentioned from 19+ (4.4+) it gets easier as you can use autoMirrored

提交回复
热议问题