我需要从主屏幕小部件启动一个对话框,所以我使用 android:theme="@android:style/Theme.Dialog"
创建了一个 Activity
问题是,我想让它看起来像标准对话框窗口(灰色背景上的按钮、字体和文本大小、填充等),如下所示:
(来源:android.com)
这是我的“对话”Activity 的样子:
是否有一些标准的方式(主题?)让它看起来像标准的系统对话框?还是我必须在自己的布局中模仿它?
最佳答案
您可以通过使用权重属性和按钮背后背景的可绘制框架来获得下面按钮的相同外观。希望这对您有所帮助!
<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/