android edittext is not scrolling

不问归期 提交于 2019-12-11 13:36:31

问题


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


回答1:


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




回答2:


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>



回答3:


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




回答4:


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"



来源:https://stackoverflow.com/questions/15071655/android-edittext-is-not-scrolling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!