重叠ScrollViews的问题

时间:2011-10-04 10:27:19

标签: android scrollview

我必须使用2个重叠的ScrollView进行布局。一个是带有“查看评论”按钮的文章。另一个视图是透明的并包含注释,并在单击“查看注释”按钮时显示在文章的顶部。问题是当评论显示并且没有填满屏幕时,触摸屏幕外的屏幕(例如,在下面显示的图像上的“Retour”按钮下方。这是一个iphone截图,android上的设计是不同的)滚动文章。

enter image description here

此外,即使其上有另一个布局,也可以点击“Voir les Commentaires”按钮。

为什么下面的视图没有被禁用(按钮,滚动...),当它上面还有另一个时?怎么办呢?

有人可以帮忙吗?

<?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="#FFFFFF">

    <RelativeLayout android:id="@+id/header"
        android:layout_width="fill_parent" android:layout_height="49dp"
        android:background="#e7e7e8">

        <!-- header -->

    </RelativeLayout>
    <ScrollView android:id="@+id/article_scroll"
        android:layout_width="fill_parent" android:layout_height="fill_parent"
        android:layout_below="@id/header">
        <LinearLayout android:layout_width="fill_parent"
            android:layout_height="fill_parent" android:orientation="vertical">

            <!-- article -->

        </LinearLayout>
    </ScrollView>

    <LinearLayout android:layout_width="fill_parent"
        android:layout_below="@id/header" android:layout_height="fill_parent"
        android:orientation="vertical" android:background="#50000000" android:visibility="gone">
        <ScrollView android:id="@+id/comment_scroll"
            android:layout_width="fill_parent" android:layout_height="fill_parent">

            <!-- comments -->

        </ScrollView>
    </LinearLayout>
</RelativeLayout>

2 个答案:

答案 0 :(得分:0)

您绝对应该使用新的活动评论并使用Transucent主题:

<activity android:theme="@android:style/Theme.Translucent">

http://developer.android.com/guide/topics/ui/themes.html

一些替代主题应该符合您的需求(例如Dialog)

或背景模糊:http://www.stealthcopter.com/blog/2010/01/android-blurring-and-dimming-background-windows-from-dialogs/

enter image description here

答案 1 :(得分:0)

对于按钮“Voir les Commentaires”,当第二层可见时,您可以将其设置为enabled = false。而且我不太确定atm,但我认为你可以对底部的ScrollView做同样的事情。