aquí dan la clase de muestra de diseño
public void showDialog() {
Dialog dialog = new Dialog(this);
Window window = dialog.getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
window.requestFeature(window.FEATURE_NO_TITLE);
dialog.setContentView(R.layout.sample);
ImageView imggameover, imgplayagain;
imggameover = (ImageView) dialog.findViewById(R.id.gameover);
imgplayagain = (ImageView) dialog.findViewById(R.id.playagain);
imgplayagain.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
startActivity(new Intent(getApplicationContext(), random.class));
onStop();
finish();
}
});
dialog.show();
}
de diálogo
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/gameoverlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/transparent"
>
<ImageView
android:id="@+id/gameover"
android:layout_width="225dip"
android:layout_height="160dip"
android:background="@drawable/gameover"
></ImageView>
<ImageView
android:id="@+id/playagain"
android:layout_width="160dip"
android:layout_height="wrap_content"
android:layout_marginLeft="100dip"
android:layout_marginTop="100dip"
android:background="@drawable/playagain"
></ImageView>
</RelativeLayout>
Gracias. Funciona. LayoutParams debe ser de android.view.WindowManager –
Tal constante está en desuso para targetSdkVersion = 22 – goRGon
No funciona en Android 4.0+. – Lazy