在整个屏幕的Android弹出布局 [英] android popup layout over the whole screen
本文介绍了在整个屏幕的Android弹出布局的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/popup_bg"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Popup"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:text="This is a simple popup" />
<Button
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="Close" />
</LinearLayout>
这是我的弹出式XML布局。但我想,这种布局几乎覆盖整个屏幕,不只是这么小。如何延长呢?我的code调用它。
this is my xml layout for popup. But i want that this layout is almost over the whole screen not just so small. How can i extend it? I call it by the code.
推荐答案
使用
android:layout_width="match_parent"
android:layout_height="match_parent"
在的LinearLayout
final Dialog dialog = new Dialog(MainAppActivity.this, R.style.PopupDialog);
dialog.setContentView(R.layout.popup);
dialog.setCancelable(true);
Button cancelButton = (Button)dialog.findViewById(R.id.close);
cancelButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
dialog.cancel();
}
});
dialog.show();
在res /价值/ styles.xml
将这个
Put this in res/values/styles.xml
<style name="PopupDialog" parent="@android:style/Theme.Translucent.NoTitleBar"></style>
这篇关于在整个屏幕的Android弹出布局的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文