且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何实现"点击任何地方对继续]事件在我的Andr​​oid活动?

更新时间:2022-02-14 22:44:43

是的,如果原来的布局是有点不恰当,使用的FrameLayout在布局的顶层实现这一目标。的FrameLayout使得堆叠的意见/布局,所以你可以有你的现有视图作为侦听触摸事件的底层,并在上面然后透明的看法:

Yes, if the original layout is somehow not appropriate, use a FrameLayout at the top level of your layout to achieve this. FrameLayout allows stackable views/layouts, so you can have your existing view as the bottom layer, and then a transparent view on top that listens for the touch event:

    <FrameLayout 
        android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <!-- Put your complete original layout/view here -->
        <View
            android:id="@+id/view_to_listen_for_touch"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
        />
    </FrameLayout>