Android:EditText没有填充ScrollView和RelativeLayout

时间:2011-02-25 19:06:04

标签: android android-edittext scrollview relativelayout

我一直在尝试用ScrollView包装我的editText,以便在内容更新时自动滚动它。我发现EditText不会覆盖整个滚动视图的问题,即使宽度和高度都设置为fill_parent。请赐教。谢谢。

以下是代码:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<Button
android:id="@+id/sendButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="send"
/>
<EditText
android:id="@+id/msgBox"
android:layout_height="wrap_content" 
android:layout_width="fill_parent" 
android:layout_alignParentBottom="true" 
android:layout_toLeftOf="@+id/sendButton"
android:gravity="left"
android:longClickable="false"
/>
<ScrollView
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:layout_above="@+id/msgBox">
<EditText  
android:id="@+id/chatBox"
android:editable="false" 
android:gravity="left|top" 
android:cursorVisible="false" 
android:longClickable="false" 
android:clickable="false"
android:autoLink="all" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent"/>
</ScrollView>
</RelativeLayout>

1 个答案:

答案 0 :(得分:21)

尝试将android:fillViewport="true"添加到ScrollView属性。这应该使它在每次内部变化时调整其大小。另外,对android:layout_height=wrap_content使用EditText。填充父本本身可以重新调整大小

是没有意义的