gpt4 book ai didi

android - Material Design 中的警告对话框

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:57:52 26 4
gpt4 key购买 nike

我就跟着这个http://www.laurivan.com/make-dialogs-obey-your-material-theme/以 Material 设计风格设计我的警报对话框。但是,我发现我还是不能和这个网站一样的风格,下面是我的代码和截图:

values-v14/styles.xml:

<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowActionBarOverlay">true</item>
<!-- colorPrimary is used for the default action bar background -->
<item name="colorPrimary">@color/colorPrimary</item>

<!-- colorPrimaryDark is used for the status bar -->
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

<item name="android:dialogTheme">@style/MyDialogTheme</item>
<item name="android:alertDialogTheme">@style/MyDialogTheme</item>
</style>

<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowCloseOnTouchOutside">false</item>
</style>

值/color.xml

<resources>
<color name="colorPrimaryDark">#3367d6</color>
<color name="colorPrimary">#4285f4</color>
<color name="windowBackgroundColor">#eeeeee</color>
<color name = "transparent">#0000</color>
</resources>

截图: enter image description here

我希望删除分隔符并且 btn 是填充正确的样式,谢谢!

最佳答案

通过新的 AppCompat v22.1,您可以使用新的 android.support.v7.app.AlertDialog .

只需使用这样的代码:

import android.support.v7.app.AlertDialog

AlertDialog.Builder builder =
new AlertDialog.Builder(this, R.style.AppCompatAlertDialogStyle);
builder.setTitle("Dialog");
builder.setMessage("Lorem ipsum dolor ....");
builder.setPositiveButton("OK", null);
builder.setNegativeButton("Cancel", null);
builder.show();

并使用这样的样式:

<style name="AppCompatAlertDialogStyle" parent="Theme.AppCompat.Light.Dialog.Alert">
<item name="colorAccent">#FFCC00</item>
<item name="android:textColorPrimary">#FFFFFF</item>
<item name="android:background">#5fa3d0</item>
</style>

您可以为所有设备使用一个样式文件。

关于android - Material Design 中的警告对话框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29813250/

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