Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android:drawableRight vs android:drawableEnd_Android_Android Drawable - Fatal编程技术网

android:drawableRight vs android:drawableEnd

android:drawableRight vs android:drawableEnd,android,android-drawable,Android,Android Drawable,如果我在按钮上使用android:drawableRight=“@drawable/my_image”: <Button android:id="@+id/my_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/my_button" android:draw

如果我在按钮上使用android:drawableRight=“@drawable/my_image”:

<Button
        android:id="@+id/my_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/my_button"
        android:drawableRight="@drawable/my_image"
        android:drawablePadding="4dp"/>

然后编辑器中的警告/建议告诉我:

考虑将android:drawableRight替换为
android:drawableEnd=“@drawable/my_image”
以更好地支持 从右到左的布局


这是什么意思?你不能再使用android:drawableRight了吗?

某些国家的语言是从右向左读的。如果您没有考虑到这一点对布局元素进行编码,您的应用程序可能无法在其设备中正确显示。基本上,将布局元素中的
替换为
开始
替换为
结束
。这既适用于XML属性,也适用于所述XML属性的。如果在开发者选项下点击强制RTL布局,您可以在从右到左的条件下查看结果并使用布局

下面是我最近使用的一个布局示例。请注意在XML属性中使用End作为XML属性的

<LinearLayout
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:layout_weight="1"
      android:gravity="end">

    <TextView
        android:id="@+id/bid_price"
        style="@style/BidPriceTextStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingEnd="10dp"
        tools:text="1000.00" />
    <TextView
        android:id="@+id/change"
        android:background="@drawable/percent_change_pill"
        style="@style/PercentChangeTextStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingStart="3dp"
        android:paddingEnd="3dp"
        tools:text="100%" />
</LinearLayout>

除了Daniel的回答之外,drawableEnddrawableStart可用于API_14+。因此,如果您使用的是minSdkVersion<14,那么除了drawableEnddrawableStart之外,还必须使用drawableRightdrawableLeft