gpt4 book ai didi

android - 使用对话框主题运行 Activity

转载 作者:行者123 更新时间:2023-11-29 00:50:34 25 4
gpt4 key购买 nike

我需要从主屏幕小部件启动一个对话框,所以我使用 android:theme="@android:style/Theme.Dialog" 创建了一个 Activity

问题是,我想让它看起来像标准对话框窗口(灰色背景上的按钮、字体和文本大小、填充等),如下所示:

alt text
(来源:android.com)

这是我的“对话”Activity 的样子:

alt text

是否有一些标准的方式(主题?)让它看起来像标准的系统对话框?还是我必须在自己的布局中模仿它?

最佳答案

您可以通过使用权重属性和按钮背后背景的可绘制框架来获得下面按钮的相同外观。希望这对您有所帮助!

             <LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/bottom_bar"
android:orientation="horizontal">
<Button
android:text="Cancel"
android:textSize="12dip"
android:id="@+id/cancelButton"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="5dip"/>
<Button
android:text="Ok"
android:textSize="12dip"
android:id="@+id/okButton"
android:layout_width="0dip"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_margin="5dip"/>
</LinearLayout>

关于android - 使用对话框主题运行 Activity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3045406/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com