Code
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:background="@null"
android:id="@+id/relativelayout"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Button
android:id="@+id/button5"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerVertical="true"
android:layout_marginEnd="9dp"
android:layout_toStartOf="@+id/button12"
android:background="@drawable/service_button_background"
android:text="Akash" />
<Button
android:id="@+id/button6"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_above="@+id/button5"
android:layout_alignStart="@+id/button7"
android:background="@drawable/service_button_background"
android:text="Sanjana" />
<Button
android:id="@+id/button7"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_alignStart="@+id/button5"
android:layout_below="@+id/button5"
android:layout_marginStart="19dp"
android:background="@drawable/service_button_background"
android:text="Sahana" />
<Button
android:id="@+id/button12"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_above="@+id/button5"
android:layout_alignParentEnd="true"
android:layout_marginBottom="30dp"
android:background="@drawable/service_button_background"
android:text="Akash" />
<Button
android:layout_width="70dp"
android:background="@drawable/service_button_background"
android:text="Akash"
android:layout_height="70dp"
android:layout_alignParentEnd="true"
android:layout_alignTop="@+id/button7"
android:layout_marginTop="30dp"
android:id="@+id/button11" />
Code
public class FloatingWindow extends Service{
WindowManager wm;
RelativeLayout ll;
LayoutInflater li;
@Override
public IBinder onBind(Intent intent) {
// TODO Auto-generated method stub
return null;
}
@Override
public void onCreate() {
// TODO Auto-generated method stub
super.onCreate();
final View myview;
li = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
wm = (WindowManager) getSystemService(WINDOW_SERVICE);
WindowManager.LayoutParams params = new WindowManager.LayoutParams(
WindowManager.LayoutParams.TYPE_INPUT_METHOD |
WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY,// | WindowManager.LayoutParams.TYPE_SYSTEM_ALERT,
WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH | WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
PixelFormat.TRANSLUCENT);
/////////////////////////Another params
params = new WindowManager.LayoutParams(
750,1250,
WindowManager.LayoutParams.TYPE_PHONE,
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
PixelFormat.TRANSLUCENT);
params.gravity = Gravity.RIGHT | Gravity.CENTER;
myview = li.inflate(R.layout.service_pie, null); // your layout here
wm.addView(myview, params);
params.x = 0;
params.y = 0
}
@Override
public void onDestroy() {
super.onDestroy();
stopSelf();
}
I have made the main layouts background as null but its still there... like how do i remove it... Meaning i have this service and when i start that service this activity will be inflated... But i want only the buttons to be inflated and not the whole activity... How do i achieve this.........................................................................