TextInputLayout多行提示?

时间:2015-12-18 06:16:21

标签: android android-edittext android-textinputlayout

我想使用android native android.support.design.widget.TextInputLayout创建一个类似于下图的EditText。

更清楚的是,提示应该以多行显示。

Image

我尝试在\n中添加转义字符string.xml,如

<string name="mobile_comp">Mobile Number \n (For chat...)</string>

当我将EditText置于TextInputLayout内时似乎无效。所以任何人都知道我在这里做错了什么?我冲浪但找不到原因?

代码

 <android.support.design.widget.TextInputLayout
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:layout_marginBottom="@dimen/text_input_margin"
                            android:layout_marginTop="@dimen/text_input_margin">

                            <com.ribbnapp.ribbn.views.EditText
                                android:id="@+id/mobile"
                                style="@style/EditText"
                                android:layout_width="match_parent"
                                android:layout_height="@dimen/edit_text_height"
                                android:layout_marginRight="80dp"
                                android:drawableLeft="@drawable/ic_mobile_number2"
                                android:drawablePadding="@dimen/drawable_padding"
                                android:hint="@string/mobile_comp"
                                android:imeOptions="actionDone"
                                android:inputType="phone"
                                android:maxLength="10"
                                android:singleLine="true"
                                android:textAppearance="?android:textAppearanceSmall" />
                        </android.support.design.widget.TextInputLayout>

Gradle依赖

 // App common
    compile 'com.android.support:appcompat-v7:23.1.0'
    compile 'com.android.support:design:23.1.0'
    compile 'com.android.support:recyclerview-v7:23.1.0'
    compile 'com.android.support:cardview-v7:23.1.0'
    compile 'com.android.support:support-v4:23.1.0'
    compile 'com.github.bumptech.glide:glide:3.6.1'
    compile "com.daimajia.swipelayout:library:1.2.0@aar"
    // Facebook SDK
    compile 'com.facebook.android:facebook-android-sdk:4.+'

1 个答案:

答案 0 :(得分:-1)

尝试添加这种方式,它正是您所寻找的

gradle这个

compile 'com.rengwuxian.materialedittext:library:2.1.4'

的Maven:

<dependency>
  <groupId>com.rengwuxian.materialedittext</groupId>
  <artifactId>library</artifactId>
  <version>2.1.4</version>
  <type>aar</type>
</dependency>

检查DartPad