[英]Android: EditText in ScrollView doesn't work properly
我有这样的布局:
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="@dimen/keyline_1"
android:layout_above="@+id/action_bar_layout"
android:orientation="vertical">
....
<EditText
android:id="@+id/message"
style="@style/ItemNewsFeedMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"/>
</ScrollView
我尝试了以下解决方案: https : //gist.github.com/laaptu/4cb395fded9a0700fcdb
不幸的是,这种行为还不正确:当我在EditText的末尾输入新闻字符时,主滚动不会同时移动,因此我看不到我的最后一个字符集。
感谢您的帮助!
您的问题不够清楚,也许这可以解决您的问题
// set request Focus
mEditText.requestFocus(View.FOCUS_RIGHT);
layout.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context=".MainActivity">
<ScrollView
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/action_bar_layout"
android:orientation="vertical">
<EditText
android:id="@+id/message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/lorem_ipsum"
android:textSize="22sp"
android:inputType="textMultiLine"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.