android edittext is not scrolling

2019-07-31 08:40发布

I have edittext. Now my edittext is wrapping content, i dont know why, i want it stay same size but be scrollable(vertical).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
    android:id="@+id/imageViewFull"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
 android:layout_weight="10"
    />

 <EditText
 android:id="@+id/editTextFull"
 android:layout_width="match_parent"
 android:layout_height="wrap_content"
 android:clickable="false"
 android:ems="10"
 android:lines="1"
 android:maxLines="5"
 android:cursorVisible="false"
 android:scrollbars="vertical"
 android:focusable="false"
  android:focusableInTouchMode="false"
 android:inputType="textMultiLine"
  >

 <requestFocus />
 </EditText>


</LinearLayout>

And in java i set text with setText

4条回答
Juvenile、少年°
2楼-- · 2019-07-31 08:50

use:

<EditText
    android:id="@+id/editTextFull"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clickable="false"
    android:ems="10"
    android:lines="1"
    android:maxLines="5"
    android:cursorVisible="false"
    android:scrollbars="vertical"
    android:focusable="false"
    android:focusableInTouchMode="false"
    android:inputType="textMultiLine"
     >

    <requestFocus />
</EditText>
查看更多
Fickle 薄情
3楼-- · 2019-07-31 08:51

Have you tried to set your layout_height="wrap_content"?

查看更多
Lonely孤独者°
4楼-- · 2019-07-31 08:57

this works for me:

<ScrollView 
    android:layout_height="200dp"
    android:layout_width="match_parent">
    <EditText
        android:id="@+id/Emsg"
        android:hint="@string/texthint"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="5dp"
        android:textColor="#02960B"
        android:textSize="18sp" />
</ScrollView>

i have set the height by android:layout_height="200dp"

查看更多
爱情/是我丢掉的垃圾
5楼-- · 2019-07-31 08:58

Try using EditText in ScrollView or take a look at this thread to make it scrollable programmatically.

查看更多
登录 后发表回答