Android的棒棒糖滚动型边缘效应的颜色棒棒糖、效应、边缘、颜色

由网友(唐伯虎点蚊香)分享简介:在我的应用程序我改变overscroll发光效果的颜色是这样的:In my app i change the overscroll glow effect color like this:int glowDrawableId = contexto.getResources().getIdentifier("over...

在我的应用程序我改变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" />
阅读全文

相关推荐

最新文章