我在滚动ListView里面遇到麻烦ScrollView.我有一个Activity在顶部有一些EditTexts,然后是一个带有两个选项卡的选项卡主机,每个选项卡都有一个ListView.当EditText视图聚焦时,软键盘出现,因为我有一个ScrollView,内容是可滚动的.但问题出现在ListViews中有更多项目(选项卡中的项目),即使有更多项目,我也无法滚动ListView.
以下是布局XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="?backgroundImage"
android:orientation="vertical">
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="50dip"
android:layout_alignParentBottom="true"
android:layout_margin="10dip"
android:id="@+id/buttons">
<Button
android:text="Save"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnSaveorUpdate"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
<Button
android:text="Cancel"
android:layout_margin="2dip"
android:textSize="20dip"
android:id="@+id/btnCancelorDelete"
android:layout_height="wrap_content"
android:layout_width="145dip"></Button>
</LinearLayout>
<ScrollView
android:layout_above="@id/buttons"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:layout_margin="10dip">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="10dip">
<TextView
android:text="Bill details"
android:textColor="?textColorDark"
android:layout_alignParentTop="true"
android:id="@+id/txtEnterDetails"
android:textSize="25dip"
android:textStyle="bold"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_marginBottom="2dip"></TextView>
<LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
android:layout_width="0dip"
android:layout_height="0dip" />
<EditText
android:layout_width="fill_parent"
android:hint="Enter data"
android:inputType="numberDecimal"
android:id="@+id/txtSample"
android:textSize="@dimen/editText"
android:layout_height="@dimen/editTextHeight"
android:text=""></EditText>
<EditText
android:layout_width="fill_parent"
android:id="@+id/txtDescription"
android:hint="Enter description"
android:textSize="@dimen/editText" …Run Code Online (Sandbox Code Playgroud) 我有一个scrollview里面有一个多行的editext .我想滚动edittext以查看较低的内容,但无法完成.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="50dp"
android:background="@android:color/holo_blue_light"
android:gravity="center" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="View Complaint"
android:textAppearance="?android:attr/textAppearanceLarge" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:padding="20dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Order Number 0100C1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Name of ClientClient 1"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="Subject : Measurement Issues"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:text="Description"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView6" …Run Code Online (Sandbox Code Playgroud) 我有一个在顶部有一些视图的布局,它应该可以与它们下面的EditText一起滚动.
EditText占用了剩余的空间,占用了所需的空间.
这是一个演示它的示例POC布局(此处仅使用了2个EditTexts):
<android.support.v4.widget.NestedScrollView android:id="@+id/nestedScrollView"
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent" android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical">
<EditText
android:id="@+id/titleEditText" android:layout_width="match_parent" android:layout_height="wrap_content"
android:ellipsize="end" android:hint="title" android:imeOptions="actionNext|flagNoExtractUi"
android:inputType="text|textAutoCorrect|textCapSentences" android:maxLines="1"
android:nextFocusDown="@id/contentEditText" android:nextFocusForward="@id/contentEditText"
android:scrollHorizontally="true" android:textColor="#2a2f3b" android:textColorHint="#a3a3a3"
android:textSize="21sp"/>
<EditText
android:id="@+id/contentEditText" android:layout_width="match_parent" android:layout_height="match_parent"
android:gravity="top" android:hint="content" android:background="@android:drawable/alert_light_frame"
android:imeOptions="actionDone|flagNoEnterAction|flagNoExtractUi" android:textSize="18sp"
android:inputType="textMultiLine|textAutoCorrect|textCapSentences"/>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Run Code Online (Sandbox Code Playgroud)
我已经设置了一个背景框架,可以直观地显示EditText的大小.
我已经找到了很多我写的解决方案,但是没有一个能够很好地处理滚动.
我一直看到的,至少是其中一个问题:
我尝试过这些解决方案:
windowSoftInputMode在清单中尝试了各种值,并尝试isNestedScrollingEnabled在NestedScrollView中进行设置.如何让底部的EditText占用尽可能多的空间,并且仍然可以滚动整个NestedScrollView,而不会出现编辑问题?
编辑:因为原来的应用程序有点复杂,底部有一些视图(在工具栏内部)当你没有专注于底部的EditText时自动隐藏,这就得到了我找不到的答案上班.
此外,我不小心将赏金给予错误的答案,所以这是一个新的赏金,在更复杂的POC上.问题保持不变.NestedScrollView应该保持在同一个地方,而不是在关注底部EditText时滚动.
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:orientation="vertical">
<View
android:layout_width="0dp" android:layout_height="0dp" android:focusable="true" …Run Code Online (Sandbox Code Playgroud) 我有一个讨厌的问题.我有EditText(8行)里面ScrollView.当我试图滚动文本时,EditText它的行为并不稳定.有时它会滚动,有时它不会聚焦.
这是我的布局文件,让我的问题更清晰:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="8dp" >
<TextView
android:id="@+id/wo_task_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/no_description" />
<TextView
android:id="@+id/wo_task_comments_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="@string/comments" />
<Button
android:id="@+id/wo_task_select_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_comment_from_template" />
<EditText
android:id="@+id/wo_task_comments"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|left"
android:hint="@string/enter_your_comment_here"
android:lines="8"
android:maxLines="10"
android:minLines="6"
android:scrollbars="vertical"
android:singleLine="false" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我知道我有这个问题,因为在另一个内部有一个可滚动的控件,但我不知道该怎么做.所以,如果可以,请帮助我.
提前致谢.
public void initComments(final View view) {
EditText comment = (EditText) view.findViewById(R.id.wo_task_comments);
comment.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View v, final MotionEvent motionEvent) {
if (view.getId() …Run Code Online (Sandbox Code Playgroud) 我已经搜索了解决方案,但似乎这些都没有用.我的情况不适用于更换xml吗?如何解决问题?滚动视图工作但edittext无法正常工作.谢谢
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/share_bg" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:overScrollMode="never" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageView
android:id="@+id/photo_area"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/share_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/photo_area"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:text="@string/share_title"
android:textColor="@android:color/white" />
<EditText
android:id="@+id/share_content"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/share_title"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/custom_textarea"
android:gravity="top|left"
android:lines="5"
android:scrollbars="vertical"
android:text="@string/default_msg" >
<requestFocus />
</EditText>
<ImageView
android:id="@+id/share_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/share_content"
android:layout_centerHorizontal="true"
android:src="@drawable/photo_taken_btn_submit" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
id:share_content是editText,谢谢