gre*_*f82 5 android material-design
我在自定义对话框首选项的布局中有一个搜索栏.我更改了styles.xml以使用新的材料设计.它的工作原理是它更改了我的设置的文本和复选框,但我无法将颜色应用到我的搜索栏.它只有在我将一个搜索栏放在一个活动中才有效,这意味着我必须在我的自定义布局中做一些事情,但我不知道是什么.我使用搜索栏发布styles.xml和布局:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="AppBaseTheme" parent="android:Theme.Material">
<!-- Main theme colors -->
<!-- your app's branding color (for the app bar) -->
<item name="android:colorPrimary">#FFFF4444</item>
<!-- darker variant of colorPrimary (for status bar, contextual app bars) -->
<item name="android:colorPrimaryDark">#FFCC0000</item>
<!-- theme UI controls like checkboxes and text fields -->
<item name="android:colorAccent">#FFFF00</item>
</style>
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
</style>
</resources>
Run Code Online (Sandbox Code Playgroud)
对话框首选项的自定义布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<SeekBar
android:id="@+id/seek_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="6dip"
android:theme="@android:style/Theme.Material"
android:layout_marginTop="6dip" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
随着棒棒糖它根本不再需要.即使在自定义首选项对话框中也可以很好地应用颜色 ~greywolf82
我想分享一些自定义Libs

您可以使用此Material Design lib,它还包括许多其他小部件.
要么

自定义搜索栏Lib DiscreteSeekBar
您不需要在 SeekBar 元素上指定 android:theme 属性。相反,您应该在 AppBaseTheme 中设置默认对话框和警报对话框主题:
<style name="AppBaseTheme" parent="android:Theme.Material">
...
<item name="android:dialogTheme">@style/AppDialogTheme</item>
<item name="android:alertDialogTheme">@style/AppAlertTheme</item>
</style>
<style name="AppDialogTheme" parent="android:Theme.Material.Dialog">
<item name="android:colorPrimary">#FFFF4444</item>
<item name="android:colorPrimaryDark">#FFCC0000</item>
<item name="android:colorAccent">#FFFF00</item>
</style>
<!-- This should extend Theme.Material.Dialog.Alert, but that style was
incorrectly hidden in L-preview. It will be fixed in a future release.
You can approximate the style using the last two MinWidth attributes.-->
<style name="AppAlertTheme" parent="android:Theme.Material.Dialog">
<item name="android:colorPrimary">#FFFF4444</item>
<item name="android:colorPrimaryDark">#FFCC0000</item>
<item name="android:colorAccent">#FFFF00</item>
<item name="android:windowMinWidthMajor">65%</item>
<item name="android:windowMinWidthMinor">95%</item>
</style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
24864 次 |
| 最近记录: |