2

Hi 'stackoverflow' I've been trying to develop an android application which should remain on top of any other activity like a transparent one and also we should be able to touch and work with other activities, but our activity should stay on top of all other activities for ever until user explicitly kills our activity.

I made my activity transparent using the following code under my

'res/layout/styles.xml'

<style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
</style>

and in my

'manifest' I used

<activity
        android:name="com.example.transperentdroid.MainActivity"
        android:theme="@style/Theme.Transparent" >
        ........
</activity>

please help me to solve this riddle. Thanks in advance.

N J
  • 27,217
  • 13
  • 76
  • 96
Chethan Shetty
  • 1,972
  • 4
  • 25
  • 45
  • You want your transparent layer to exist throughtout your application lifecycle or throughout the whole system lifecycle? Assuming it is the second one, you should probably create a Service and in it take control of the display buffer, of the system layout manager and of the system input service. Are you sure it can be done? – type-a1pha Jul 19 '13 at 07:23
  • Yes it can be done @type-a1pha because other applications are already been built in such a manner. – Chethan Shetty Jul 19 '13 at 07:32
  • Can you give a link of an example somehow, if possible? In either case, you can't achieve this by using an Activity since your Activity will be stopped when the user will press the back or the home button. – type-a1pha Jul 19 '13 at 07:38

2 Answers2

0

at your activity layout file, in the attributes of parent layout item put this,

android:background="#000000"
Onur A.
  • 3,007
  • 3
  • 22
  • 37
0

res/values/styles.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <style name="Theme.Transparent" parent="android:Theme">
    <item name="android:windowIsTranslucent">true</item>
    <item name="android:windowBackground">@android:color/transparent</item>
    <item name="android:windowContentOverlay">@null</item>
    <item name="android:windowNoTitle">true</item>
    <item name="android:windowIsFloating">true</item>
    <item name="android:backgroundDimEnabled">false</item>
  </style>
</resources>

(the value @color/transparent is the color value #00000000 which I put in res/values/color.xml file. You can also use @android:color/transparent in later Android versions)

<activity android:name=".SampleActivity"android:theme="@android:style/Theme.Translucent.NoTitleBar">
...
</activity>
dharmendra
  • 7,835
  • 5
  • 38
  • 71
  • thanks for your time, but not working, I cant touch the icon of behind activity. – Chethan Shetty Jul 19 '13 at 09:38
  • of course you not , you are calling one more activity there is no interface connection can happen between those two activity , try same thing using views in single activity – dharmendra Jul 19 '13 at 10:04
  • Ok @dhams thanks, but I'll tell you what I'm really trying to achieve, lets say `activity A (our Mainactivity)` is `transparent` running on top of all other activities, but I want other icons which are also visible to be able to touch by user. Is it possible ? – Chethan Shetty Jul 19 '13 at 13:09
  • @ChethanShetty no its not , try to do same thing in one activity , using multiples views – dharmendra Jul 19 '13 at 13:27