触摸事件在scrollview中不起作用

时间:2014-03-26 10:54:47

标签: android

在此代码中,触摸事件(从左到右和从右到左)不起作用。如果我删除ScrollView并将RelativeLayout替换为LinearLayout,则触摸事件正在运行。并且所有小部件都重叠在一起。请尽快解决我的问题。

触摸事件(从右到左,从左到右)在xml文件中使用scrollview时无效。如何使用触摸事件管理两个scrollview。 hnextpage.xml页面是。

请告诉我先生,我们如何管理它。

<?xml version="1.0" encoding="utf-8"?>
    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="match_parent">
      <RelativeLayout 
            android:layout_width="match_parent"
      android:layout_height="wrap_content" >
           <TextView    
                android:id="@+id/marquee_txt"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:gravity="center"
                android:text="@string/marquee"
                android:singleLine="true"
                android:ellipsize="marquee"
                android:focusable="true"
                android:paddingTop="4dp"
                android:freezesText="true"

                android:textSize="20sp"
                android:marqueeRepeatLimit="marquee_forever"
                android:scrollHorizontally="true"
                android:textColor="@android:color/white"
                android:textStyle="bold"
                android:background="@color/abs__background_holo_dark" />


      <!-- Name Label -->
      <TextView android:id="@+id/name_label"

                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_margin="5dp"
                android:layout_below="@+id/img"
                android:layout_marginTop="7dp"
                android:textColor="#000000"/>

      <!-- Description Label -->
      <TextView android:id="@+id/description_label"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:layout_alignParentTop="true"
                android:gravity="top"
                android:textSize="20sp"
                android:layout_below="@+id/marquee_txt"
                android:layout_marginBottom="20dp"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="30dp"
                android:textColor="#dc6800"/>

       <ImageView 
                android:id="@+id/img"
                android:layout_width="200dp"
                android:layout_height="200dp"
                android:layout_marginLeft="5dp"
                android:layout_marginTop="5dp"
                android:src="@drawable/du_logo"
                android:layout_below="@+id/description_label"
                android:contentDescription="@string/desc"
                android:layout_centerHorizontal="true"/>


      <!-- Price Label 

                android:src="@drawable/ic_logo"
      -->
      <TextView android:id="@+id/date_label"
                  android:layout_width="match_parent"
                  android:layout_height="match_parent"
                  android:layout_margin="5dp"
                  android:layout_below="@+id/name_label"
                  android:textColor="#000000"
                  android:textSize="18sp"
                  android:gravity="left"
                  android:layout_marginBottom="150dp"
                  />
          </RelativeLayout>
    </ScrollView>

1 个答案:

答案 0 :(得分:0)

尝试将ScrollView布局高度从match_parent更改为wrap_content:

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

之前有效:Android ScrollView not working properly