【问题标题】:Tunning up Activity with dialog theme使用对话框主题调整 Activity
【发布时间】:2010-06-15 13:09:48
【问题描述】:

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

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


(来源:android.com

这就是我的“对话”活动的样子:

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

【问题讨论】:

    标签: android android-widget android-layout


    【解决方案1】:

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

                 <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>
    

    【讨论】:

      【解决方案2】:

      顶部对话框是使用AlertDialog.Builder 构建的,要创建一个简单的对话框,您应该使用该类。

      【讨论】:

      • 我不能。此对话框在按下主屏幕小部件按钮后启动。我必须使用 PendingIntent 来启动它。
      猜你喜欢
      • 2016-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多