Android的棒棒糖滚动型边缘效应的颜色 [英] android lollipop scrollview edge effect color

查看:2072
本文介绍了Android的棒棒糖滚动型边缘效应的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用程序我改变overscroll发光效果的颜色是这样的:

In my app i change the overscroll glow effect color like this:

int glowDrawableId = contexto.getResources().getIdentifier("overscroll_glow", "drawable", "android");
Drawable androidGlow = contexto.getResources().getDrawable(glowDrawableId);
assert androidGlow != null;
androidGlow.setColorFilter(getResources().getColor(R.color.MyColor), PorterDuff.Mode.SRC_ATOP);

但是,当我更新到棒棒糖此code崩溃。我得到以下错误code:

But when i updated to lollipop this code crashes. I get following error code:

FATAL EXCEPTION: main
Process: com.myproject.myapp, PID: 954
android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1233)
at android.content.res.Resources.getDrawable(Resources.java:756)
at android.content.res.Resources.getDrawable(Resources.java:724)

看来,overscroll_glow资源的棒棒糖失踪。 我怎样才能做到这一点棒棒糖?

Seems that overscroll_glow resource is missing in lollipop. How can i achieve this in lollipop?

在此先感谢。

推荐答案

您可以指定安卓colorEdgeEffect 在你的主题,你的整个应用程序内改变overscroll发光颜色。默认情况下,继承由设置主色值的android:colorPrimary

You can specify android:colorEdgeEffect in your theme to change the overscroll glow color within your entire app. By default, this inherits the primary color value set by android:colorPrimary.

RES /价值/的themes.xml:

res/values/themes.xml:

<style name="MyAppTheme" parent="...">
    ...
    <item name="android:colorEdgeEffect">@color/my_color</item>
</style>

另外,你可以修改这个值,使用内联主题覆盖的单一视图。

Alternatively, you can modify this value for a single view using an inline theme overlay.

RES /价值/的themes.xml:

res/values/themes.xml:

<!-- Note that there is no parent style or additional attributes specified. -->
<style name="MyEdgeOverlayTheme">
    <item name="android:colorEdgeEffect">@color/my_color</item>
</style>

RES /布局/ my_layout.xml:

res/layout/my_layout.xml:

<ListView
    ...
    android:theme="@style/MyEdgeOverlayTheme" />

这篇关于Android的棒棒糖滚动型边缘效应的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆