2016-08-24 59 views
1

Image为什么drawableLeft出现在EditText之外?

为什么图标出现在EditText/divider之前?

这里是我的代码:

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:id="@+id/fragment_sign_in" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:padding="5dp" 
tools:context="com.*.*.*.SignInFragment"> 

    <!-- This is the EditText --> 
    <com.rey.material.widget.EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:drawableStart="@drawable/email" 
    android:drawableLeft="@drawable/email" 
    android:padding="0dp" 
    android:hint="test" 
    app:et_dividerHeight="1dp" /> 

</android.support.constraint.ConstraintLayout> 
+0

从0使填充到某个值。 – Pankaj

回答

2

您可以使用

android:drawablePadding="5dp" // Add your own values 

垫料的可绘制和文本之间。

必须是尺寸值,这是一个浮点数所附 具有单位如“14.5sp”。可用单位为:px(像素),dp (与浓度无关的像素),sp(基于首选 字体大小的缩放像素),单位为英寸,毫米(毫米)。

您可以

android:drawableLeft="2dp" 
android:paddingLeft="3dp" 

提拉被吸引到该文本的左侧尝试。

+1

先生他用'com.rey.material.widget.EditText'可能这个库会支持这个属性吗? –

+1

@jaydroider哦。我以为它的用户自定义类先生 –

+1

我认为这个属性不会被库所识别,他使用的可能是它有它自己的'填充属性'。 –

0

enter image description here

我用下面的代码对上述的EditText:

<EditText 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:drawableStart="@drawable/abc_ic_menu_copy_mtrl_am_alpha" 
     android:drawableLeft="@drawable/abc_ic_menu_copy_mtrl_am_alpha" 
    /> 
+1

他已经使用'com.rey.material.widget.EditText'可能这个库不会支持这个属性。 –

+0

如果它具有与我拥有的代码相同的代码,它如何解决我的问题? –

相关问题