Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How come the behavior of drawableStart doesn't match the Android documentation?

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>

According to the documentation for drawableStart,

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

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

enter image description here

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

"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?

like image 328
Nathan Osman Avatar asked Mar 12 '13 00:03

Nathan Osman


1 Answers

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."

You must read :

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

like image 99
A. Ferrand Avatar answered Nov 06 '22 07:11

A. Ferrand