How can I load the strings.xml dynamically? Can I put the file in a server?

前端 未结 2 576
小蘑菇
小蘑菇 2021-01-23 01:39

Why i ask this is because the size of my APK is huge. I wanna make it smaller.

There\'re lots of strings in strings.xml. Our product manager force us to support all lan

2条回答
  •  北海茫月
    2021-01-23 02:26

    can I just put some languages of strings.xml locally, put others in a server, then when user launches the app, downloads the strings.xml from it dynamically according to the language of the user.

    You cannot modify resources at runtime. You are welcome to download and process XML files at runtime, and those XML files might contain strings that you want to display to the user. However, you cannot use the Android resource system to pull in those strings. You would need to write your own Java code that uses those values, including determining which translation to use for a given device (taking into account the multiple-locale support offered in Android 7.0).

提交回复
热议问题