如何与半透明的Android应用程序背后的元素进行交互? [英] How can I interact with elements behind a translucent Android app?

查看:81
本文介绍了如何与半透明的Android应用程序背后的元素进行交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经找到了如何为我的android应用创建半透明背景,但是到目前为止,我还没有找到如何与其背后的内容进行交互(例如主屏幕).

I have found how to create a translucent background for my android app, but so far I haven't found how to interact with what's behind it (the home screen for example).

这篇文章帮助我完成了应用程序视图为半透明.

This post helped me make the app view translucent.

如何允许用户与半透明应用程序背后的内容进行交互? 此应用程序是一个很好的应用示例,它允许使用透明屏幕" Android应用.

How would one go about allowing the user to interact with what's behind the translucent app? This app is a good example of an app that allows this is the "Transparent Screen" Android app.

推荐答案

了解视图堆叠的一种非常简单的方法是拿一本书(任何一本书).将每个页面都视为一个视图.

A very simple way of understanding stacking of views is to take a book (any book). Think of each page as a view.

可见度

  • 打开书本时,您会看到一个页面(主视图-VISIBLE)
  • 当您翻到当前页面时,您可以看到下一页(INVISIBLE-主视图以显示下一个视图.请记住,您只是隐藏视图,如果将可见性设置为GONE,则相当于撕裂的当前页面以查看下一页.)
  • When you open the book you can see a page (Main View - VISIBLE)
  • When you turn the current page you can see the next page (INVISIBLE - Main View to show the next view. Remember you are only hiding the view, if you set the visibility to GONE this is equivalent to tearing of the current page to view the next page.)

触摸场景

  • 假设您的第一页是蜡质页面(类似于您的半透明视图的半透明页面),那么您可以看到基础页面
  • 当您尝试触摸第二页上的图形时,尽管您可以在第二页上看到该图形,但您正在触摸第一页.从第二页到第一页都不可能触及该图.

别灰心,因为这是您要处理的观点,而不是论文,您仍然可以做您想做的事情:)

Don't be disheartened, since it is a view you will be dealing with and not a paper you can still do what you want to do :)

  • 对两个视图都实施View.OnTouchListener
  • 要半透明查看您收到的任何触摸事件,请在方法onTouch
  • 中返回FALSE
  • Android会将touch事件传递给您的基础视图.
  • Implement View.OnTouchListener for both your views
  • For translucent view any touch events you get, return FALSE in the method onTouch
  • Android will pass on the touch event to your underlying view.

这篇关于如何与半透明的Android应用程序背后的元素进行交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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