首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >android在整个屏幕上的弹出式布局

android在整个屏幕上的弹出式布局
EN

Stack Overflow用户
提问于 2013-03-18 17:19:38
回答 1查看 665关注 0票数 0
代码语言:javascript
运行
复制
<?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布局。但我希望这个布局几乎覆盖整个屏幕,而不仅仅是这么小。我如何扩展它?我用代码来称呼它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-03-18 17:31:21

使用

代码语言:javascript
运行
复制
android:layout_width="match_parent"
android:layout_height="match_parent"

LinearLayout

代码语言:javascript
运行
复制
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/values/styles.xml中

代码语言:javascript
运行
复制
<style name="PopupDialog" parent="@android:style/Theme.Translucent.NoTitleBar"></style>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15473222

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档