使用TextInputLayout

时间:2016-12-30 17:46:00

标签: android android-layout android-fragments

在我的应用程序中,我想创建一个允许用户输入标题文本和内容文本的UI。但是内容文本应该填满屏幕的整个剩余区域以及' textBottomType'应该在屏幕的底部。 我怎样才能确保' textInputContent'将填满整个空屏区域?我用UI尝试了不同的东西,下面是我的代码。

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/content_user_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_user_view">

        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputHeader"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="2dp">
                <AutoCompleteTextView
                    android:id="@+id/textInputHeaderInformation"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:hint="Enter Your Header"
                    android:inputType="text"
                    android:maxLines="1"
                    />
        </android.support.design.widget.TextInputLayout>

        <android.support.design.widget.TextInputLayout
            android:id="@+id/textInputContent"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_below="@+id/textInputHeader"
            android:padding="2dp">
            <EditText
                android:id="@+id/textInputContentInformation"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:hint="Enter Your Content"
                android:inputType="text"
                android:layout_weight="1"
                />
        </android.support.design.widget.TextInputLayout>

        <LinearLayout android:orientation="horizontal" android:layout_marginTop="12dp"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/background1"
            android:layout_below="@+id/textBottomType"
            android:layout_alignParentStart="true">
            <ImageView android:src="@android:drawable/ic_popup_reminder" android:layout_margin="@dimen/card_margin"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            <TextView android:text="Important Information"
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:textAlignment="center"
                android:textStyle="normal|bold"
                android:textColor="@color/winter"
                android:textSize="18sp" />
        </LinearLayout>
</RelativeLayout>

当前Incorect视图...... Current UI view

这就是我希望我的观点...... Expected UI view

谢谢,

IamHuM

2 个答案:

答案 0 :(得分:0)

将Edittext的inputType属性设置为textMultiLine:

run port $ logger . allowCsrf . corsified $ app cfg

答案 1 :(得分:0)

我修改了代码,如下所示。感谢 Vivek ,以便您快速回复。

       <EditText
            android:id="@+id/textInputContentInformation"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:hint="Enter Your Notes Content"
            android:inputType="text|textAutoComplete|textMultiLine|textLongMessage"
            android:layout_weight="1"
            android:maxLines="1000"
            />
相关问题