2013-11-27 207 views
0

我正在尝试添加一个用于输入文本的框。这个盒子的侧面应该有一个小滚动条。使用这段代码,我得到的是一个空行,我可以输入多行文本。有谁知道我可以如何使用滚动条获得包装盒?在edittext中不显示滚动条

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 


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

回答

0

滚动视图中的EditText不会显示滚动条。要显示edittext的滚动条,请使用下面的代码,为此您不需要使用scrollview即可摆脱它。

android:inputType="textMultiLine" 

滚动型可以显示滚动条,只有当它含有比其高度尺寸多个元素

的EditText的典型为例在滚动条:

<EditText 
     android:id="@+id/editText1" 
     android:layout_width="wrap_content" 
     android:layout_height="100dp" 
     android:layout_alignLeft="@+id/search_query" 
     android:layout_alignParentBottom="true" 
     android:inputType="textMultiLine" > 

</EditText> 
+0

您好感谢这么much..that作品! :) – gazubi