Creating an overlay activity

倾然丶 夕夏残阳落幕 提交于 2019-12-13 04:34:55

问题


I am trying to create a overlay activity which is sitting in a corner of the screen taking a very small portion of the screen, while the rest of the screen is interactive that is I tap on anything that is displaying on rest of the screen. So far I am unsuccessful in obtaining my goal. I have added these properties to my window but they don't seem to work.

hello.xml:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:layout_width="50dp"
   android:layout_height="match_parent"
   android:orientation="vertical"
   android:id="@+id/tepp" >
</RelativeLayout>

What can I do to solve this problem?


回答1:


From what I can remember, only one Activity can be active at any given time. So while that small Activity in the corner is running, the other activitys will be paused and you wont be able to interact with them. You should try using a Fragment instead. You can have multiple fragments visible at the same time. Although I believe that only one Fragment can be active at any given time like an Activity, when you click on different fragments, the one you click on becomes active and you can interact with it. This might help you achieve what your looking for.




回答2:


i don't think that there is such a thing "an overlay activity" .

however, instead of using an activity, you could make the view on top, like i've shown here . when the user touches it, you would need to decide what would happen, and if you need to expand its size to be larger to show something else to the user...

btw, if all the activity does is to create an on top view, you can call finish() right at the end of the onCreate() method. also you can avoid using setContentView in case you inflate the view anyway...



来源:https://stackoverflow.com/questions/18494727/creating-an-overlay-activity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!