如何在android中使编辑文本可滚动?

时间:2013-07-05 14:30:36

标签: android android-layout

我正在为一个活动开发UI。在该活动中,我添加了一个滚动视图。在该滚动视图中,我添加了一个线性布局&在那个线性布局中,我添加了一个编辑文本。现在我想将编辑文本设置为可滚动,以便如何实现?

3 个答案:

答案 0 :(得分:3)

试试这段代码..

  // For horizontal scroll  
 android:scrollHorizontally="true"  

  //For vertical scroll
 android:scrollbars = "vertical"

答案 1 :(得分:3)

您无法在scrollview中放置滚动视图

<ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="100dp" >


        <EditText
            android:id="@+id/editText1"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:text="KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK" >

            <requestFocus />
        </EditText>

    </ScrollView>

答案 2 :(得分:0)

XML ,您可以尝试使用..

<EditText
    android:id ="@+id/editInput"
    android:layout_width ="0dip" 
    android:layout_height ="wrap_content" 
    android:layout_weight ="1" 
    android:inputType="textCapSentences|textMultiLine"
    android:maxLines ="4" 
    android:maxLength ="2000"   />

否则,请遵循这些..