2016-12-30 123 views
0

在我的應用程序中,我想要創建一個UI,它將允許用戶輸入標題文本和內容文本。但內容文本應該填充屏幕的整個剩餘區域,'textBottomType'應該位於屏幕的底部。 我如何確保'textInputContent'將填滿整個空白屏幕區域?我用UI做了不同的事情,下面是我的代碼。用TextInputLayout填充整個屏幕區域

<?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

回答

0

將Edittext的inputType屬性設置爲textMul tiLine:

android:inputType="textMultiLine" 
+0

我做了更改,這是它的外觀。在這個問題中,「輸入您的內容」下方的文本是單行文本,但我希望用戶在此輸入多行文本。我如何讓用戶輸入多行文本,以便整個屏幕可以充滿內容文本。 – IamHuM

+0

在主要問題中添加了當前用戶界面和預期用戶界面的圖像。 – IamHuM

+0

我修改後的代碼如下圖所示 – IamHuM

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" 
      />