更改微调箭头,应用程序兼容性V21箭头、兼容性、应用程序

2023-09-06 07:06:08 作者:安如她心如她梦,

我有我的主题我的自​​定义主题的活动,但对于微调我选用与应用程序兼容性V21的风格,但我得到这个:

i have activities which i themed with my custom theme, but for spinner i choosed to style it with Appcompat v21 but i got this :

那么如何改变微调箭头是黑色或蓝色,如果有没有办法?

我发现这是类似的问题,但没有任何回答:添加自定义微调箭头这里是我的微调:

i found this as similar question but doesn't have any answer : add custom spinner arrow here is my spinner :

<Spinner
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:id="@+id/spinner2"
        android:layout_marginTop="10dp"
        android:layout_centerInParent="true" />

我用这个样式的微调:

i used this to style the spinner:

 <style name="MyTheme.SpinnerAppTheme" parent="Widget.AppCompat.Spinner">
    </style>

这是我如何使用适配器

   ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                getBaseContext(), R.array.listMedRes, android.R.layout.simple_spinner_item);

我只是想主题微调,非常感谢

i just want to theme the spinner , thanks alot

推荐答案

由于您使用的应用程序兼容性-V21,你可以利用这种新材料的设计风格优势属性:

Since you are using AppCompat-v21, you can take advantage of the new material design styles attributes:

colorPrimary :在应用栏你的应用的品牌颜色,适用于操作栏

colorPrimary: your app branding color for the app bar, applies to action bar

colorPrimaryDark :状态栏暗变种和上下文应用栏

colorPrimaryDark: darker variant for the status bar and contextual app bars

colorAccent :您可以定义亮补充到主品牌的颜色。默认情况下,这是(通过colorControlActivated)应用框架控制颜色

colorAccent: lets you define bright complement to the primary branding color. By default, this is the color applied to framework controls (via colorControlActivated)

colorControlNormal :在正常状态下向框架控制颜色

colorControlNormal: color applied to framework controls in their normal state

colorControlActivated :在应用框架控制其活化

colorControlActivated: applied to framework controls in their activated

下面是一个例子

styles.xml

<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
    <!-- colorPrimary is used for the default action bar background -->
    <item name="colorPrimary">@color/primary</item>
    <!-- colorPrimaryDark is used for the status bar -->
    <item name="colorPrimaryDark">@color/primary_dark</item>
    <!-- colorAccent is used as the default value for colorControlActivated which is used to tint widgets -->
    <item name="colorAccent">@color/accent</item>
    <item name="colorControlNormal">@color/primary</item>
</style>

colors.xml

<resources>
    <color name="primary">#ff0000ff</color>
    <color name="primary_dark">#ff0000af</color>
    <color name="accent">#870000ff</color>
    <color name="white">#ffffffff</color>
</resources>

下面是如何看起来

希望这有助于。

 
精彩推荐
图片推荐