为什么drawableStart行为的Andr​​oid文档不匹配? [英] How come the behavior of drawableStart doesn't match the Android documentation?

查看:200
本文介绍了为什么drawableStart行为的Andr​​oid文档不匹配?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个非常基本的布局:

I have created a very basic layout:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <Button
            android:id="@+id/button1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="Button"
            android:drawableStart="@drawable/ic_launcher" />

    </LinearLayout>
</RelativeLayout>

根据 drawableStart 文档

的绘制被吸引到该文本的开始。

"The drawable to be drawn to the start of the text."

但是,当我的Andr​​oid 4.0.4的手机上运行,​​而不是我看到这一点:

However, when run on my Android 4.0.4 phone, I instead see this:

为什么会出现图标和文本之间如此大的差距?根据这个答案

Why is there such a large gap between the icon and the text? According to this answer,

有了Android 4.0(API级别14)可以使用Android。drawableStart属性将在文本的开始绘制

"With Android 4.0 (API level 14) you can use android:drawableStart attribute to place a drawable at the start of the text."

不过这不是我观察到的行为。为什么不属性的工作?

But this is not the behavior I observe. Why isn't the attribute working?

推荐答案

很多与开始和结束的误解。

开始结束在布局XML 是替代为离开,以匹配布局方向(LTR或RTL)。


所以,当文档说:

A lot of misunderstanding with start and end.
Start and End in layout xml are alternative to left and right to match layout direction (LTR or RTL).

So, when documentation says :

的绘制被吸引到该文本的开始。

"The drawable to be drawn to the start of the text."

您必须阅读:

的绘制将按照布局方向绘制到视图的开头

"The drawable to be drawn to the beginning of the view according to layout direction"

这篇关于为什么drawableStart行为的Andr​​oid文档不匹配?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆