【发布时间】:2015-09-01 15:01:44
【问题描述】:
我想全屏显示图像,然后在用户按下它时关闭它。
我正在使用一个对话框,它占据了大约 80% 的屏幕。我的图像周围有一个白色边框(它不在我的文件系统中)。
如何让这个对话框全屏显示?
SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
boolean viewedInstructions = sharedPreferences.getBoolean("instructions_viewed", false);
if (!viewedInstructions) {
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("instructions_viewed", true);
editor.commit();
final Dialog d = new Dialog(this);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
d.setContentView(R.layout.instructions_dialog);
d.findViewById(R.id.tutorial).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
d.dismiss();
}
});
d.show();
布局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/dialog_layout_root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical"
android:padding="10dp"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/tutorial"
android:src="@drawable/dashboard_instructions"/>
</LinearLayout>
【问题讨论】:
-
您是否尝试使用@android:style/Theme.Translucent.NoTitleBar 作为您的对话框样式?
-
如何更改对话框的主题?
标签: android dialog viewgroup layoutparams