0

I would like to display a single button on the top of another application. Skype for example.

I tried making an activity having a RelativeLayout and inside it i put a Button. But I couldn't make it in a way that the RelativeLayout is not touchable while the Button is Touchable. So i'm thinking of a way to do that by displaying only the Button when Skype is opened. So i'll be able to use skype and the button together in the same time.

The things i've tried using are :

getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);

but that made the whole Window not touchable ( including the Button inside the RelativeLayout)

I was thinking if there is some method like :

(RelativeLayout)findViewById(R.id.relativeLayout1).makeNotTouchable() (Button)findViewById(R.id.button1).makeTouchable();

Please note that the above methods don't exist i'm just trying to make it clearer for you to understand what I would like to achieve.

Please note also that making the activity Translucent prevents the user from passing the touch events to the activity just behind it. It can display the activity behind it but we cannot pass the touch events through it.

ARMAGEDDON
  • 939
  • 3
  • 11
  • 23
  • Here's a similair question: [creating a system overlay (always on top) button in android](http://stackoverflow.com/questions/4481226/creating-a-system-overlay-always-on-top-button-in-android) – Victor May 31 '13 at 16:41

1 Answers1

0

You can accomplish this by setting the FLAG_NOT_TOUCH_MODAL on the WindowManager LayoutParams. You should also set the theme of the activity to @android:style/Theme.Translucent.NoTitleBar to make the window translucent.

I forgot to mention you have to change the size of the Window. You can accomplish this using the following as an example:

    getWindow().setGravity(Gravity.CENTER);
    getWindow().setLayout(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT);
Bobbake4
  • 24,509
  • 9
  • 59
  • 94
  • can you please give me the piece of code i don't know how to set FLAG_NOT_TOUCH_MODAL for views ... I really appreciate your help bro – ARMAGEDDON May 31 '13 at 16:17
  • It's the same as you have above, getWindow().addFlags(WindowManager.LayoutParams. FLAG_NOT_TOUCH_MODAL); you just have the wrong flag. – Bobbake4 May 31 '13 at 16:21
  • same as before :( the button is being touchable and the relativelayout is always there and being touchable. While i only want the button to be touchable – ARMAGEDDON May 31 '13 at 16:34
  • See edits, you can mess with window settings to adjust the position. – Bobbake4 May 31 '13 at 16:45