gpt4 book ai didi

android - 如何在 RTL 布局中直接在图像上使用 "autoMirrored"属性

转载 作者:搜寻专家 更新时间:2023-11-01 08:54:27 24 4
gpt4 key购买 nike

在 xml 中使用“autoMirrored”标志,现在可以很容易地在 android 4.4 Kitkat 中进行 drawable 的镜像。但是有什么办法可以在不使用 xml 的情况下直接使用应用程序中使用的各种图像资源来做到这一点?

最佳答案

您可以以编程方式使用 setAutoMirrored在 Drawable 上:

ImageView image = (ImageView) findViewById(R.id.image);

Drawable arrow = getResources().getDrawable(R.drawable.ic_right_arrow);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
if (arrow != null) {
arrow.setAutoMirrored(true);
}
}

image.setImageDrawable(arrow);

关于android - 如何在 RTL 布局中直接在图像上使用 "autoMirrored"属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20090977/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com