根据语言选择更改图片

时间:2017-06-23 00:25:18

标签: android android-imageview android-resources

是否可以根据手机的语言选择更改imageView?

这是我在xml中使用的代码,我想要的是,如果有某种方式,当它处于某种语言时,图像将更改为相应的语言,因为在图像中输入了文本。

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">

   <RelativeLayout
       android:layout_width="match_parent"
       android:layout_height="match_parent">

    <ImageView
        android:layout_width="360dp"
        android:layout_centerHorizontal="true"
        android:layout_height="wrap_content"
        android:src="@drawable/calculate_wavelength_stepversion"
        android:id="@+id/imageExample"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/desarrollo"
        android:layout_marginRight="10dp"
        android:layout_below="@+id/imageExample"
        android:layout_marginLeft="10dp"
        android:layout_marginTop="10dp" />


   </RelativeLayout>

</FrameLayout>

2 个答案:

答案 0 :(得分:2)

是的,您可以像这样创建res / drawable-en-rCA /或res / drawable-fr-rCA /,您可以参考AliasResourcesthis

答案 1 :(得分:0)

在java类中使用某些逻辑,当您检测到某种语言更改时,请将图像的内容设置为不同的drawable。

相关问题