Reputation: 35074
I have to make custom (I can set my layout.xml) floating window where I can control Xco and Yco.
With Toast (in timer) I can achieve this but I have to avoid unnecessary timer.
I come across some library say, SuperToolTip (we can't control X and Y; rather we placed against some drawable) StandOut (here we can control Xco and Yco but it uses Services for just a simple thing)
Please help me.
EDITED
final Dialog dialog = new Dialog(MainActivity.this, android.R.style.Theme_Translucent_NoTitleBar);
Window window = dialog.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.x = 0;
wlp.y = 200;
wlp.width = 800;
wlp.height= 400;
window.setAttributes(wlp);
dialog.setTitle(null);
View view = getLayoutInflater().inflate(R.layout.layout_audio_recording_hint, null);
dialog.setContentView(view);
dialog.setCancelable(false);
ImageButton imgBtnCloseDialog = (ImageButton)view.findViewById(R.id.imgBtnCloseDialog);
imgBtnCloseDialog.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.cancel();
}
});
ImageButton imgBtnAudio = (ImageButton) findViewById(R.id.imgBtnAudio);
imgBtnAudio.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.show();
}
});
Upvotes: 1
Views: 1740
Reputation: 381
Use this Code android.widget.PopupWindow can be used to display an arbitrary view. The popup windows is a floating container that appears on top of the current activity.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@android:color/background_light">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="@android:color/darker_gray">
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="20dp">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="It's a PopupWindow" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/ic_launcher" />
<Button
android:id="@+id/dismiss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dismiss" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Upvotes: 1