在 ScrollView 和 ViewFlipper 中启用 Scrollable EditText [英] Enable Scrollable EditText within a ScrollView and ViewFlipper

查看:17
本文介绍了在 ScrollView 和 ViewFlipper 中启用 Scrollable EditText的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 ViewFlipper 中有两个布局,每个布局中都包含 ScrollView.但是,我的 EditText 不起作用,我知道原因是由于 ScrollView.但是,尽管我尝试了 Disable ScrollView action 中的答案,但没有一个对我有用.我的xml在哪里有问题吗?我的xml如下所示:

I have a two layout in a ViewFlipper which contains ScrollView in each of the layout. However, my EditText does not work and I know the reason is due to the ScrollView. However, though I tried the answers in Disable ScrollView action , none worked for me. Is there a problem with my xml some where? My xml is such shown below:

PageFlipper

PageFlipper

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" 
android:layout_height="fill_parent"
android:background="#FFF"
android:id="@+id/flipperlayout"
android:orientation="vertical">

<!-- Header -->

<include
    android:id="@+id/include1"
    layout="@layout/prepostheader" />

    <RelativeLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"
    android:background="#FFF"
    android:orientation="vertical">

<Button
    android:id="@+id/btnPage2"
    style="@style/PageBtnFont"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/include1"
    android:layout_marginTop="2dp"
    android:layout_marginRight="5dp"
    android:background="@drawable/button"
    android:text="Page 2" />

<Button
    android:id="@+id/btnPage1"
    style="@style/PageBtnFont"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignBaseline="@+id/btnPage2"
    android:layout_alignBottom="@+id/btnPage2"
    android:layout_toLeftOf="@+id/btnPage2"
    android:layout_marginRight="5dp"
    android:background="@drawable/button"
    android:text="Page 1" />
</RelativeLayout>


<ViewFlipper
    android:id="@+id/flipper" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent">        


    <include layout="@layout/prepostform" 
        android:adjustViewBounds="true"/>
    <include layout="@layout/prepostform2" 
        android:adjustViewBounds="true"/>

</ViewFlipper>

第1页

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/editFormLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFF"
android:orientation="vertical" >

<ScrollView
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/scrollView"
    android:layout_weight="1"
    android:padding="5px">

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:adjustViewBounds="true"
    android:src="@drawable/formprepost" />



<EditText
    android:id="@+id/name"
    android:layout_width="400dp"
    android:layout_height="35dp"
    android:layout_alignParentRight="true"
    android:layout_below="@+id/include1"
    android:layout_marginRight="90dp"
    android:layout_marginTop="134dp"
    android:background="#0000"
    android:ellipsize="start"
    android:inputType="textCapWords|textPersonName"
    android:lines="1"
    android:maxLines="1"
    android:textAppearance="@style/TextStyle1" >

</EditText>

<EditText
    android:id="@+id/school"
    android:layout_width="400dp"
    android:layout_height="35dp"
    android:layout_marginTop="-8dp"
    android:layout_alignLeft="@+id/name"
    android:inputType="textCapWords|textPersonName"
    android:background="#0000"
    android:textAppearance="@style/TextStyle1"
    android:ellipsize="start"
    android:maxLines = "1"
    android:lines = "1"
    android:layout_below="@+id/name" />

<EditText
    android:id="@+id/supervisor"
    android:layout_width="400dp"
    android:layout_height="35dp"
    android:layout_marginTop="-9dp"
    android:layout_alignLeft="@+id/school"
    android:inputType="textCapWords|textPersonName"
    android:background="#0000"
    android:textAppearance="@style/TextStyle1"
    android:ellipsize="start"
    android:maxLines = "1"
    android:lines = "1"
    android:layout_below="@+id/school" />

<EditText
    android:id="@+id/date"
    android:layout_width="200dp"
    android:layout_height="35dp"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/supervisor"
    android:layout_marginLeft="185dp"
    android:inputType="textCapWords|textPersonName"
    android:textAppearance="@style/TextStyle1"
    android:background="#0000"
    android:ellipsize="start"
    android:maxLines="1"
    android:layout_marginTop="116dp">
</EditText>

<CheckBox
    android:id="@+id/tick1"
    android:layout_width="540dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:button="@drawable/checkbox_selector"
    android:layout_below="@+id/date"
    android:layout_marginLeft="154dp"
    android:layout_marginTop="43dp"/>

<CheckBox
    android:id="@+id/tick2"
    android:layout_width="240dp"
    android:layout_height="wrap_content"
    android:layout_marginTop="-11dp"
    android:layout_alignLeft="@+id/tick1"
    android:button="@drawable/checkbox_selector"
    android:layout_below="@+id/tick1"/>

<CheckBox
    android:id="@+id/tick3"
    android:layout_width="270dp"
    android:layout_height="wrap_content"
    android:layout_alignLeft="@+id/tick2"
    android:layout_marginTop="-12dp"
    android:button="@drawable/checkbox_selector"
    android:layout_below="@+id/tick2" />




<EditText
    android:id="@+id/comment1"
    android:layout_width="614dp"
    android:layout_height="180dp"
    android:layout_alignParentLeft="true"
    android:layout_alignRight="@+id/tick1"
    android:layout_below="@+id/tick3"
    android:layout_marginLeft="94dp"
    android:layout_marginTop="23dp"
    android:gravity="top|left"
    android:inputType="textCapSentences|textMultiLine"
    android:textAppearance="@style/TextStyle1" >

</EditText>

<EditText
    android:id="@+id/comment2"
    android:layout_width="614dp"
    android:layout_height="165dp"
    android:layout_alignLeft="@+id/comment1"
    android:layout_alignRight="@+id/comment1"
    android:layout_below="@+id/comment1"
    android:layout_marginTop="90dp"
    android:gravity="top|left"
    android:inputType="textCapSentences|textMultiLine" />

<ImageButton
    android:id="@+id/signature1"
    android:layout_width="170dp"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/date"
    android:layout_below="@+id/comment1"
    android:layout_marginLeft="49dp"
    android:background="#0000"/>

<ImageButton
    android:id="@+id/signature2"
    android:layout_width="170dp"
    android:layout_height="50dp"
    android:layout_alignLeft="@+id/supervisor"
    android:layout_below="@+id/comment2"
    android:background="#0000" />

推荐答案

主要活动类:

您可以通过以下方式执行此操作,还可以查看此链接

You can Perform this below way and also see this link

 EditText EtOne = (EditText) findViewById(R.id.comment1);
    EtOne.setOnTouchListener(new OnTouchListener() {
                @Override
                public boolean onTouch(View v, MotionEvent event) {
                    if (v.getId() == R.id.comment1) {
                        v.getParent().requestDisallowInterceptTouchEvent(true);
                        switch (event.getAction() & MotionEvent.ACTION_MASK) {
                        case MotionEvent.ACTION_UP:
                            v.getParent().requestDisallowInterceptTouchEvent(false);
                            break;
                        }
                    }
                    return false;
                }
            });

这篇关于在 ScrollView 和 ViewFlipper 中启用 Scrollable EditText的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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