android edittext设置paddingLeft无效


图片描述


 <RelativeLayout
        android:id="@+id/login_email_rl"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/login_launcher" >

        <EditText
            android:id="@+id/login_edit_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:background="@drawable/login_email_bg_normal"
            android:gravity="center_vertical"
            android:hint="@string/login_user_hint"
            android:minHeight="40dp"
            android:paddingBottom="2dp"
            android:paddingLeft="35dp"
            android:paddingRight="26dp"
            android:paddingTop="1dp"
            android:textColor="@color/text_dark"
            android:textColorHint="@color/text_hint"
            android:textSize="15sp" />

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:layout_marginLeft="50dp"
            android:src="@drawable/login_email" />
    </RelativeLayout>

eclipse 里面可以,android studio里面就有问题了。
麻烦大家帮我看一下!

Android android-studio

兰迪斯丨翔 10 years ago

 <EditText
            android:id="@+id/login_edit_email"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="40dp"
            android:layout_marginRight="40dp"
            android:background="@drawable/login_email_bg_normal"
            android:gravity="center_vertical"
            android:hint="@string/login_user_hint"
            android:minHeight="40dp"
            android:paddingBottom="2dp"
            android:paddingLeft="35dp"
            android:paddingRight="26dp"
            android:paddingTop="1dp"
            android:drawableLeft="@drawable/search_icon"
            android:textColor="@color/text_dark"
            android:textColorHint="@color/text_hint"
            android:textSize="15sp" />

wokaka answered 10 years ago

你的布局有点问题,用相对布局将图片放在左边,edittext放在右边就ok了。

tamer answered 10 years ago

android:drawableLeft="@drawable/search_icon"
你应该要的是这个

NiceLyt answered 10 years ago

Your Answer