2017-10-20 115 views
0

我想管理多行編輯文本控件相對於設備屏幕高度的高度。高度應該是屏幕的40%。xamarin android如何通過屏幕高度增加多行編輯文本高度?

我已經使用了最大線條,線條和最小線條屬性。如果我設置了這些屬性,那麼高度確實會改變,但是如果屏幕高度改變或者設備轉移到水平,那麼編輯文本將不在屏幕上。總之,多行編輯文本高度必須是動態的,並且屏幕大小。它應該隨着屏幕尺寸的其他控制而縮小和擴大。

截圖:

enter image description here

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:focusableInTouchMode="true" 
android:background="#e8eeff"> 
<EditText 
    android:id="@+id/etTextMultiLine" 
    android:inputType="textMultiLine" 
    android:gravity="top|left" 
    android:layout_height="wrap_content" 
    android:layout_width="match_parent" 
    android:scrollbars="vertical" 
    android:hint="Enter a Text" 
    android:background="@layout/EditTextStyle" 
    android:textColorHint="#404144" 
    android:textColor="#404144" 
    android:layout_marginLeft="5dp" 
    android:layout_marginRight="5dp" 
    android:layout_marginTop="5dp" 
    android:padding="5dp" /> 

回答

0

既然你想用百分比來實現大小,可以考慮使用PercentFrameLayout作爲您的EditText的父母,只是同時匹配的體重和身高。該文檔說PercentFrameLayout已被棄用,因此請考慮建議的替換,ConstraintLayout。