简体   繁体   English

材料设计输入文字

[英]Material Design Input Text

Is there a way to create an input field that looks like the ones on this image - Icon on the left, input on the right - using only the default TextInputLayout ? 有没有一种方法可以仅使用默认的TextInputLayout创建一个类似于该图像的输入字段-左侧的图标,右侧的输入?

I've tried several combinations, and the icon always stays inside the TextInputEditText . 我尝试了几种组合,并且图标始终停留在TextInputEditText I've tried changing the TextInputLayout orientation to horizontal but it didn't work as well. 我尝试将TextInputLayout方向更改为水平,但效果不佳。 Is there anyway of doing this without placing an ImageView and an EditText inside of another ViewGroup ? 有没有这样做,而不将ImageViewEditText放置在另一个ViewGroup

Below is the code I used to create an input field, but with the icon remains inside the TextInputEditText . 下面是我用于创建输入字段的代码,但图标保留在TextInputEditText

<android.support.design.widget.TextInputLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="Test"
        >
        <android.support.design.widget.TextInputEditText
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:drawableStart="@drawable/ic_bank_card_back_grey_24dp"
            android:drawablePadding="@dimen/default_padding"            
            />
    </android.support.design.widget.TextInputLayout>

材料设计输入文字

Does this fit the bill ? 这符合要求吗? :

<android.support.design.widget.TextInputLayout
    android:id="@+id/TextInputLayout1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >  

    <android.support.v7.widget.AppCompatEditText
        android:id="@+id/EditText1"
        android:hint="code"
        android:text="0044"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:imeOptions="actionNext"
        android:inputType="phone"
        android:minWidth="350dp"
        android:drawableLeft="@drawable/cross"
        android:drawableStart="@drawable/cross"
        android:textColor="#00ff00"
        android:textColorHint="#ff0000"
        android:textCursorDrawable="@null"
        />
</android.support.design.widget.TextInputLayout>

image from code: 图片来自代码: 图片中的图片

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM