2011-09-09 10 views
0

内のコンテンツに合うように私はこのような行のための私のレイアウトの中に定義しています複数行のEditTextフィールドがあります。MutliLineのEditTextのサイズ変更がExpandableListView

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="320dp" android:layout_height="wrap_content" 
android:background="@color/lightblue" android:focusable="false"> 
<RelativeLayout android:layout_width="fill_parent" 
    android:layout_height="wrap_content" android:layout_marginLeft="14dp" 
    android:layout_marginTop="4dp" android:layout_marginRight="14dp" android:focusable="false"> 
    <TextView android:textSize="12dp" android:layout_height="wrap_content" 
     android:layout_width="wrap_content" android:id="@+id/tvLabel" 
     android:width="80dp" android:textColor="@color/lbl_color_alt" 
     android:text="LABEL:" android:layout_marginRight="18dp"></TextView> 
    <EditText android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:id="@+id/etValue"   
     android:layout_toRightOf="@+id/tvLabel" 
     android:singleLine="false" android:gravity="top|left" 
     android:minLines="3"    
     android:inputType="textAutoCorrect|textCapSentences|textMultiLine" 
     android:imeOptions="normal" android:textSize="12dp"    
     /> 
</RelativeLayout> 

を私はminLines属性を調整することができEditTextはサイズが大きくて収縮します。しかし、フィールドには、事前入力されたコンテンツに基づいてサイズを調整する必要があります。したがって、コンテンツに6行が含まれている場合、それに応じて高さが調整されます。これを可能にするためにコードで何かする必要がありますか?最終的には、onTextChangedリスナーでも高さを再調整する必要があります(iPhoneに似ています)。

+0

だから質問は何ですか? EditTextは、追加のコードなしで内容に応じて自動的に高さを調整します。また、 'getLineCount()'や 'getLineHeight()'メソッドなどもあります。 – jamapag

答えて

0

コード内の行の高さをsetLines()でプログラムで設定していたため、EditTextがコンテンツに基づいて調整されていませんでした。私はこのプロジェクトの初期段階でこれをやっていて、すべてを忘れていました。

関連する問題