public class SelfDialog {
Dialog mDialog;
public SelfDialog(Context context) {
mDialog = new Dialog(context, R.style.dialog);
mDialog.setContentView(R.layout.dialog);
Window window = mDialog.getWindow();
WindowManager.LayoutParams wl = window.getAttributes();
wl.x = 0;
wl.y = 2;
window.setAttributes(wl);
}
}
dialog.xml(这个文件当然可以自己定义成自己想要的):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/RelativeLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300sp" android:layout_height="190sp"
android:background="@drawable/belle_frame">
<TextView android:layout_marginTop="5dp" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="this is the test text!!!this is the test text!!!" />
</RelativeLayout>