在嵌套的Scrollview中单击Edittext可以滚动外部的scrollview [英] Clicking on Edittext inside nested Scrollview scrolls outer scrollview

查看:94
本文介绍了在嵌套的Scrollview中单击Edittext可以滚动外部的scrollview的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含各种布局的父horizo​​ntalScrollview.在一种特定的布局中,有一个滚动视图.在该滚动视图内部有edittext. 现在,当我单击任何编辑文本进行输入时,水平滚动视图会自动将屏幕滚动到其他布局,而我看不到当前的活动布局(包含滚动视图).

I have a parent horizontalScrollview that contains various layouts. In one particular layout there is a scrollview. Inside that scrollview there is edittext. Now when I click on any edittext for input, the horizontal scrollview automatically scrolls the screen to some other layout and I am not able to see the current active layout(containing scrollview).

我知道嵌套的滚动视图是一种不好的编码习惯,但是在这种情况下我无法更改它,因为会有大量的返工.有什么解决方法吗?

I know nested scrollviews is a bad coding practice but I can not change it in this case as there will be large amount of rework. Is there any workaround for this.

以下是包含horizo​​ntalscrollview的主布局的xml代码:-

Following is the xml code for main layout containing horizontalscrollview:-

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

<HorizontalScrollView
    android:id="@+id/CloudHScrollView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />
</RelativeLayout>

和以下是在以后某个阶段插入的子布局之一的代码.此布局包含具有edittexts的滚动视图:-

and following is the code for one of the child layouts that is inserted later at some stage. This layout contains the scrollview which has edittexts:-

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ScrollView
    android:id="@+id/scrollview"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="0dp"
    android:background="@drawable/blueoverlay"
    android:fillViewport="true" >

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingBottom="300dp"
        android:paddingTop="90dp" >

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <EditText
                android:id="@+id/edittext"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:background="@null"
                android:gravity="right"
                android:singleLine="true"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:textColor="@android:color/black" />
        </LinearLayout>
    </LinearLayout>
</ScrollView>

推荐答案

我遇到了同样的问题,通过将以下内容添加到AndroidManifest.xml文件中相应的活动来解决了这个问题.

I had the same issue, solved it by adding the following to AndroidManifest.xml file for the corresponding activity.

android:windowSoftInputMode="adjustResize"

这篇关于在嵌套的Scrollview中单击Edittext可以滚动外部的scrollview的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆