2013-02-25 75 views
1

我有edittext。現在我的edittext包裝內容,我不知道爲什麼,我希望它保持相同的大小,但可以滾動(垂直)。android edittext不滾動

<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> 

而且在Java中我設定setText

+0

請提交完整的佈局文件,但我認爲layout_weight正在導致您的問題 – 2013-02-25 16:34:06

+0

@Saksak我提交完整的佈局文件 – 2013-02-25 17:11:35

+0

您是否嘗試刪除重量並檢查? – 2013-02-25 17:46:22

回答

2

設置高度嘗試使用EditTextScrollView或看看this線程使它以編程方式滾動。

+1

使其可編程滾動。 – 2013-02-25 17:56:22

0

文本您是否嘗試過設置你的layout_height="wrap_content"

+0

這是行不通的 – 2013-02-25 17:08:43

+0

我只是意識到我有一個'ScrollView'內的整個佈局。嘗試其中一個答案。它應該工作。 – TronicZomB 2013-02-25 17:12:05

1

使用:

<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> 
0

這個工作對我來說:

<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> 

我有android:layout_height="200dp"