如何把Android的Holo主题风格的对话框按钮对话框、按钮、风格、主题

由网友(倦题红叶诗)分享简介:我在霍洛主题创建一个对话框,并要遵循显示按钮的操作系统默认的方式。到目前为止,我已经创建了对话框,但按钮不呈现它在河洛为ICS做了应用程序的方式。我怎样才能做到这一点?我打算外观和放大器;手感而我能够达成到这里I'm creating a Dialog Box on Holo Theme and want to f...

我在霍洛主题创建一个对话框,并要遵循显示按钮的操作系统默认的方式。到目前为止,我已经创建了对话框,但按钮不呈现它在河洛为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"
阅读全文

相关推荐

最新文章