简体   繁体   中英

Fit text into an EditText Android

I´m using an EditText to put a specific text with editText.setText(string) , I'm trying to match the height of EditText to the lines of my String, but I can´t.

If I take my EditText and write normal, it works well, but I need to put the text with setText() .

Can someone help me?

例

            <EditText
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:singleLine="false"
                android:id="@+id/text_description"
                android:maxLength="500"
                android:focusableInTouchMode="false"
                android:layout_weight="0" />

In your XML file set the android:layout_height attribute to wrap_content like this :

<EditText
   android:layout_width="match_parent"
   android:layout_height="wrap_content"
   ...../>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM