Hua*_*yun 4 android android-alertdialog android-dialog material-design
我只需按照http://www.laurivan.com/make-dialogs-obey-your-material-theme/来设计我的alertdialog的材料设计风格.但是,我发现我仍然无法像这个网站一样,以下是我的代码和截图:
值-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>
Run Code Online (Sandbox Code Playgroud)
值/ color.xml
<resources>
<color name="colorPrimaryDark">#3367d6</color>
<color name="colorPrimary">#4285f4</color>
<color name="windowBackgroundColor">#eeeeee</color>
<color name = "transparent">#0000</color>
</resources>
Run Code Online (Sandbox Code Playgroud)
截图:

我想删除分隔符,btn是填充正确的样式,谢谢!
Gab*_*tti 10
使用新的,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();
Run Code Online (Sandbox Code Playgroud)
并使用这样的风格:
<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>
Run Code Online (Sandbox Code Playgroud)
您可以为所有设备使用单一样式文件.
| 归档时间: |
|
| 查看次数: |
12049 次 |
| 最近记录: |