由国家Android绘制的Drawables

时间:2013-06-18 15:28:43

标签: android resources translation drawable

我正在将我的应用翻译成几种语言,但现在我正在努力解决问题!我有一些带有文字的图片,有一种方法可以使用国家代码提供可绘制的资源吗?如果我使用国家/地区代码将drawable添加到我的应用程序它将增加应用程序的大小?我不会因为这些图像而没有现在1MB的应用程序是4或5。

谢谢!

3 个答案:

答案 0 :(得分:4)

等于你设置不同的语言与res目录值-es值-fr值... 您可以使用以下目录为每个位置设置不同的drawable:

drawable-es drawable-fr ... http://developer.android.com/training/basics/supporting-devices/languages.html

请记住,目录的额外信息具有特殊重要性,您应该放置正确的位置http://developer.android.com/guide/topics/resources/providing-resources.html 例如,drawable-es-hdpi

你的apk大小的问题我想你不需要为所有国家设置你所有的图像差异,不是吗?通常你只需要配置一些图像

答案 1 :(得分:0)

是的,可以为每个国家/地区提供资源。请查看此答案,详细了解如何操作:Localization and drawables

肯定会增加您应用的尺寸。就像软件开发中的其他任何东西一样,它在性能(或图像质量)和资源(在这种情况下,apk的大小)之间进行折衷。为避免以指数方式增加应用程序的大小,您可以尝试为每个区域设置而不是国家/地区提供资源,或者只是提供hdpi版本。

答案 2 :(得分:0)

如果您不想使用不同的drawable增加apk的大小,您可以编写自定义ImageView并使用String(将被翻译)在其上设置文本或将textView放在其上ImageView将它们设置在这样的relativelayout中:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"    
  android:gravity="center"
  android:orientation="vertical"
 >

<ImageView
    android:id="@+id/yImage"
    android:layout_width="fill_parent"
    android:layout_height="25dp"/>  

<TextView
    android:id="@+id/yTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBottom="@+id/yImage"
    android:layout_alignLeft="@+id/yImage"
    android:layout_alignRight="@+id/yImage"
    android:layout_alignTop="@+id/yImage"
    android:background="@color/transparent"
    android:lines="2"
    android:textColor="@color/Black"
    android:textSize="14sp"
    android:textStyle="bold" />
</RelativeLayout>

使用框架布局也很容易。

相关问题