【问题标题】:Setting a Style for a popUpWindow为 popUpWindow 设置样式
【发布时间】:2011-10-21 03:58:16
【问题描述】:

我正在开发一个需要类似于弹出窗口的应用程序。我正在考虑两种不同的设计。 popUpWindow 作为普通 popUpWindow 打开而不启动新活动的设计和弹出窗口作为新活动打开的另一种设计。在后一种设计中(打开了一个新活动),我可以通过在清单的活动标签中添加以下行来使新窗口看起来非常漂亮:

android:theme="@android:style/Theme.Dialog"

但是,开始一项新活动似乎不适用于我的整体设计。我的问题是如何将这种“对话框”样式应用于常规 popUpWindow?

下面是我实例化并显示 popUpWindow 的代码:

PopupWindow popUpWindow;
popUpWindow = new PopupWindow(this);
popUpWindow = new PopupWindow(popUpView, 250, 325, true);
popUpWindow.showAtLocation(mainLinearLayout, Gravity.CENTER, 0, 10);

【问题讨论】:

  • 我已经添加了处理popUpWindow的代码,这是你的想法吗?

标签: android android-activity styles themes popupwindow


【解决方案1】:

这是我最终实现的目标:

    Dialog dialog = new Dialog(MainActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    popUpLayout = Globals.layoutInflater.inflate(R.layout.pop_up_layout,
            null);
    dialog.setContentView(popUpLayout);
    dialog.getWindow().setLayout(275, 350);
    dialog.show();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-09
    • 1970-01-01
    相关资源
    最近更新 更多