问题
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