[英]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.