如何把Android的Holo主题风格的对话框按钮 [英] How to Android Holo Theme style dialog box buttons

查看:166
本文介绍了如何把Android的Holo主题风格的对话框按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在霍洛主题创建一个对话框,并要遵循显示按钮的操作系统默认的方式。到目前为止,我已经创建了对话框,但按钮不呈现它在河洛为ICS做了应用程序的方式。 我怎样才能做到这一点? 我打算外观和放大器;手感 而我能够达成到这里

I'm creating a Dialog Box on Holo Theme and want to follow the OS default way of displaying the buttons. So far I have created the dialog box but the buttons don't render in the way it does in the apps done in Holo for ICS. How can I do this? My intended look & feel is and I am able to reach till here

推荐答案

晚了一点,但也许有人仍感兴趣。

a bit late, but maybe someone is still interested in that.

这个工程pretty的对我好。

this works pretty good for me.

...
<!--
EDIT: be carefull, "?android:attr/dividerHorizontal" is only supported since API 11
      just avoid it in prior OSs.
-->
<View
    android:layout_width="fill_parent"
    android:layout_height="1dip"
    android:background="?android:attr/dividerHorizontal" />
<LinearLayout 
    style="?android:attr/buttonBarStyle"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:paddingTop="0dip"
    android:paddingLeft="2dip"
    android:paddingRight="2dip"
    android:measureWithLargestChild="true">

    <Button 
        android:id="@+id/cancel"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@android:string/cancel"/>
    <Button 
        android:id="@+id/ok"
        style="?android:attr/buttonBarButtonStyle"
        android:layout_width="0dip"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="@android:string/ok"/>
</LinearLayout>
...

加载此布局的活动需要的Holo.Dialog主题。

the activity that loads this layout needs the Holo.Dialog theme.

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

这篇关于如何把Android的Holo主题风格的对话框按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆