GithubHelp home page GithubHelp logo

bilibili / magicasakura Goto Github PK

View Code? Open in Web Editor NEW
3.5K 96.0 468.0 2.97 MB

MagicaSakura 是 Android 多主题框架。~ is an Android multi theme library which supporting both daily colorful theme and night theme.

Home Page: http://app.bilibili.com

License: Apache License 2.0

Java 100.00%
android-library theme multi-theme multicolor colorful vector svg

magicasakura's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

magicasakura's Issues

一个很奇怪的问题

<com.bilibili.magicasakura.widgets.TintTextView
    android:id="@+id/tv_name"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textSize="?attr/eStatusTextSize"
    android:textColor="@color/emotion_item_tv_color_selector"/>

当textColor 设置为一个selector 然后 textSize设置主题里面的字体大小
在AppCompatCompoundDrawableHelper.loadFromAttribute 出现异常:
android.content.res.Resources$NotFoundException:Resource "com.caij.emore:dimen/status_text_size_16" (7f0900b0) is not a Drawable (color or path): TypedValue{t=0x5/d=0xf01 a=5 r=0x7f0900b0}

但是不是必现的。

请问我如果使用google原生的BottomNavigationView来当做底部的导航,可以让导航栏选中切换成当前的主题色吗?

下面是我的布局代码,也就是谷歌原生的底部导航

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/window_background"
    tools:context=".ui.main.MainActivity">

    <android.support.design.widget.BottomNavigationView
        android:id="@+id/navigation"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_alignParentBottom="true"
        android:background="?android:attr/windowBackground"
        app:elevation="5dp"
        app:itemTextColor="@color/color_navigation_view"
        app:itemIconTint="@color/color_navigation_view"
        app:menu="@menu/navigation"/>

    <android.support.v4.view.ViewPager
        android:visibility="visible"
        android:id="@+id/viewPager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_above="@id/navigation"
        android:overScrollMode="never">
    </android.support.v4.view.ViewPager>

</RelativeLayout>

v4 包更新版本有错误

compile "com.android.support:appcompat-v7:${rootProject.ext.supportVersion}" compile "com.android.support:design:${rootProject.ext.supportVersion}" compile "com.android.support:gridlayout-v7:${rootProject.ext.supportVersion}"
在demo里面 ,把rootProject.ext.supportVersion 有25.3.1 升级到27.1.0 的时候ThemeUtils ``的getWrapperDrawable方法报错。
public static Drawable getWrapperDrawable(Drawable drawable) { if (drawable instanceof android.support.v4.graphics.drawable.DrawableWrapper) { return ((android.support.v4.graphics.drawable.DrawableWrapper) drawable).getWrappedDrawable(); } else if (drawable instanceof android.support.v7.graphics.drawable.DrawableWrapper) { return ((android.support.v7.graphics.drawable.DrawableWrapper) drawable).getWrappedDrawable(); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && drawable instanceof android.graphics.drawable.DrawableWrapper) { return ((android.graphics.drawable.DrawableWrapper) drawable).getDrawable(); } return drawable; } v4下的DrawableWrapper找不到。是升级版本的原因吗?

夜间模式

您好,请问哔哩哔哩动画中的夜间模式是怎么实现的?我在demo里做了修改,但是只是改变了toolbar、文字等控件的颜色,界面的背景色还是白色的。

夜间模式

您好,请问能不能补充说明一下夜间模式的使用步骤啊,或者在demo中加个夜间模式的例子,看了好几天还是没明白用您的这个library怎么处理一个模式设置不同控件变成不同颜色。

TintAppBarLayout中嵌套CollapsingToolbarLayout和TintToolbar,折叠后toolbar颜色问题

布局文件如下:
问题:1,折叠后toolbar是透明的,颜色不知道怎么设置,demo也没有??
2,状态栏必须在每个activity的onpostcreat()方法中,设置状态栏么??
3,怎么设置默认值?能否在application中设置?

<com.bilibili.magicasakura.widgets.TintAppBarLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/theme_color_primary"
    android:fitsSystemWindows="true"
    android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">


    <android.support.design.widget.CollapsingToolbarLayout
        android:id="@+id/coll_toolbar_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/detail_image_height"
        android:fitsSystemWindows="true"
        app:expandedTitleMarginEnd="96dp"
        app:expandedTitleMarginStart="48dp"
        app:layout_scrollFlags="scroll|exitUntilCollapsed">


        <ImageView
            android:id="@+id/detail_image"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:fitsSystemWindows="true"
            app:layout_collapseMode="parallax" />

        <View
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="bottom"
            android:background="@drawable/black_bg" />

        <com.bilibili.magicasakura.widgets.TintToolbar
            android:id="@+id/toolbar"
            android:layout_width="match_parent"
            android:layout_height="?attr/actionBarSize"
            android:backgroundTint="@color/theme_color_primary"
            app:layout_collapseMode="pin" />

    </android.support.design.widget.CollapsingToolbarLayout>

    <android.support.design.widget.TabLayout
        android:id="@+id/tab_layout"
        android:layout_width="match_parent"
        android:layout_height="@dimen/tablayout_height"
        android:visibility="gone"
        app:tabIndicatorColor="@color/white"
        app:tabSelectedTextColor="@color/white"
        app:tabTextColor="@color/white" />
</com.bilibili.magicasakura.widgets.TintAppBarLayout>

<com.jude.easyrecyclerview.EasyRecyclerView
    android:id="@+id/recycler_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    app:scrollbarStyle="insideOverlay" />

<RelativeLayout
    android:id="@+id/rl_progress"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/white"
    android:visibility="visible">

    <ProgressBar
        android:id="@+id/pb_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true" />

    <TextView
        android:id="@+id/tv_progress"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerInParent="true"
        android:padding="@dimen/padding_16"
        android:text="@string/tryagain"
        android:textColor="@color/text_primary_color"
        android:textSize="@dimen/textsize_16" />
</RelativeLayout>

请教EditText中设置tintBackgroud的问题

EditText中设置tintBackgroud对默认背景无法生效,需要和官方demo一样自己设置图片背景才会生效。 看了源码,没找到其中为什么不生效。(tintBackgroud默认背景在普通状态下生效,在选中状态下不生效)

tintimageview 图片切换

@ColorRes
int getThemeColorId(Context context, int colorId, String theme) {
    switch (colorId) {
        case R.color.theme_color_primary:
            return context.getResources().getIdentifier(theme, "color", getPackageName());
        case R.color.theme_color_primary_dark:
            return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName());
        case R.color.theme_color_primary_trans:
            return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName());
    }
    return colorId;
}

private
@ColorRes
int getThemeColor(Context context, int color, String theme) {
    switch (color) {
        case 0xfffb7299:
            return context.getResources().getIdentifier(theme, "color", getPackageName());
        case 0xffb85671:
            return context.getResources().getIdentifier(theme + "_dark", "color", getPackageName());
        case 0x99f0486c:
            return context.getResources().getIdentifier(theme + "_trans", "color", getPackageName());
        case R.drawable.yellow_one:
            return context.getResources().getIdentifier(theme + "_one", "drawable", getPackageName());
        case R.drawable.red_two:
            return context.getResources().getIdentifier(theme + "_two", "drawable", getPackageName());
    }
    return -1;
}











        case R.drawable.yellow_one:
            return context.getResources().getIdentifier(theme + "_one", "drawable", getPackageName());
        case R.drawable.red_two:
            return context.getResources().getIdentifier(theme + "_two", "drawable", getPackageName());
    使用不行?

gradle 无法同步

Error:(2, 0) No service of type Factory available in ProjectScopeServices.

好像是这个 依赖打不开
apply plugin: 'com.github.dcendents.android-maven'

File877b48d4afc0.png)

自定义Tintable控件issue

作者您好,在下准备写一个继承TabLayout并且实现Tintable接口时发现,AppCompatBackgroundHelper的loadFromAttribute不是public,希望作者能放开这个方法好让群众更加方便的去实现自己的Tintable控件,
阿里嘎多

请问TintEditText光标颜色要如何适配

demo中edittext_cursor.xml修改为

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <size android:width="1dp" />
    <solid android:color="@color/theme_color_primary_trans" />
</shape>

光标颜色并不会变化

在ListView上面使用出现item混乱

使用ListView的话,如果滑动到一定距离,有些item被复用的话,切换Theme,这时候ListView当前页面的item成功换色,但是再次滑动会出现被复用的换色前的item,请问这个问题如何解决的?

release版本编译阶段报错

1、Warning:com.bilibili.magicasakura.widgets.TintGridLayout: can't find referenced method 'boolean isInEditMode()' in program class com.bilibili.magicasakura.widgets.TintGridLayout
已查到原因,建议增加混淆规则
2、希望能增加Switch控件支持

TintProgressBar不显示

我在新建的App里使用TintProgressBar时设置了app:progressIndeterminateTint="@color/theme_color_primary"
时就显示不出来这个TintProgressBar了,不设置这个属性的时候才可以显示。

切换主题后的一些问题

  1. 八种颜色,第一种粉色,点击切换后没反应。其他的颜色切换都可以。
  2. 切换了主题后 状态栏变色,但是进入下一个页面,状态栏又回到了原来的颜色。但是标题栏和控件是改变了的

我在基类的Activity里设置的监听切换,所有上下文都是同一个。

在vivo x5xl机型上报错

app已经上线了,只有在这个机型会报错,不知道什么原因。

android.view.InflateException: Binary XML file line #32: Error inflating class com.bilibili.magicasakura.widgets.TintRadioButton
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at cn.geekdream.jhglsy.fragments.BaseFragment.onCreateView(BaseFragment.java)
at android.support.v4.app.Fragment.performCreateView(Fragment.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java)
at android.support.v4.view.ViewPager.populate(ViewPager.java)
at android.support.v4.view.ViewPager.populate(ViewPager.java)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2391)
at android.view.View.measure(View.java:16926)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2469)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1385)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1655)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1262)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6456)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5351)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:829)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:645)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
... 62 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x0
at android.content.res.Resources.getValue(Resources.java:1159)
at android.content.res.VivoResources.getValue(VivoResources.java:175)
at android.content.res.Resources.getColor(Resources.java:831)
at cn.geekdream.jhglsy.JhglsyApplication.replaceColor(JhglsyApplication.java)
at com.bilibili.magicasakura.utils.ThemeUtils.replaceColor(ThemeUtils.java)
at com.bilibili.magicasakura.utils.DrawableUtils.getAttrColor(DrawableUtils.java)
at com.bilibili.magicasakura.utils.DrawableUtils.getAttrColorFilter(DrawableUtils.java)
at com.bilibili.magicasakura.utils.StateListDrawableInflateImpl.inflateDrawable(StateListDrawableInflateImpl.java)
at com.bilibili.magicasakura.utils.DrawableUtils.createFromXmlInner(DrawableUtils.java)
at com.bilibili.magicasakura.utils.DrawableUtils.createDrawable(DrawableUtils.java)
at com.bilibili.magicasakura.utils.TintManager.getDrawable(TintManager.java)
at com.bilibili.magicasakura.widgets.AppCompatCompoundButtonHelper.loadFromAttribute(AppCompatCompoundButtonHelper.java)
at com.bilibili.magicasakura.widgets.TintRadioButton.(TintRadioButton.java)
at com.bilibili.magicasakura.widgets.TintRadioButton.(TintRadioButton.java)
... 65 more
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at cn.geekdream.jhglsy.fragments.BaseFragment.onCreateView(BaseFragment.java)
at android.support.v4.app.Fragment.performCreateView(Fragment.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java)
at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java)
at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java)
at android.support.v4.view.ViewPager.populate(ViewPager.java)
at android.support.v4.view.ViewPager.populate(ViewPager.java)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at android.support.v7.internal.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1616)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:729)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:601)
at android.view.View.measure(View.java:16926)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5411)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:332)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2391)
at android.view.View.measure(View.java:16926)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2469)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1385)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1655)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1262)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6456)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:788)
at android.view.Choreographer.doCallbacks(Choreographer.java:591)
at android.view.Choreographer.doFrame(Choreographer.java:560)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:774)
at android.os.Handler.handleCallback(Handler.java:808)
at android.os.Handler.dispatchMessage(Handler.java:103)

使用CoordinatorLayout,切换夜间模式后Glide加载的图片没有了

这是我的布局文件
如果直接设置本地图片不用Glide加载,切换后图片没有异常,但是用Glide加载,切换夜间模式后图片就没有了

<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ImageView
            android:id="@+id/iv_logo_past_week"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/x70"
            android:layout_marginRight="@dimen/x70"/>

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_horizontal"
            android:layout_marginTop="@dimen/x9"
            android:text="fdsafsdafassad"
            android:textColor="#aaa"
            android:textSize="@dimen/x13"/>

    </LinearLayout>

        <com.ajguan.library.EasyRefreshLayout
            android:id="@+id/refreshlayout"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/pageBehavior">

            <android.support.v7.widget.RecyclerView
                android:id="@+id/rv"
                android:layout_width="match_parent"
                android:layout_height="match_parent"/>

        </com.ajguan.library.EasyRefreshLayout>

</android.support.design.widget.CoordinatorLayout>

关于ProgressBar的问题

AppCompatProgressBarHelper.loadFromAttribute(){
TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0);
if (array.hasValue(0)) {
mProgressTintResId = array.getResourceId(0, 0);
setSupportProgressTint(array.getColorStateList(0));
}
if (array.hasValue(1)) {
mIndeterminateTintResId = array.getResourceId(1, 0);
setSupportIndeterminateTint(array.getColorStateList(1));
}
array.recycle();
}

改成下面
AppCompatProgressBarHelper.loadFromAttribute(){
TypedArray array = mView.getContext().obtainStyledAttributes(attrs, ATTR, defStyleAttr, 0);
if (array.hasValue(0)) {
mProgressTintResId = array.getResourceId(0, 0);
setSupportProgressTint(hemeUtil.getThemeColorStateList(mProgressTintResId));
}
if (array.hasValue(1)) {
mIndeterminateTintResId = array.getResourceId(1, 0);
setSupportIndeterminateTint(ThemeUtil.getThemeColorStateList(mIndeterminateTintResId));
}
array.recycle();
}

这样可以避免replaceColor这个方法里面替换颜色 感觉这个方法太不可靠了, 只需要replaceColorById 这个里面替换颜色id就行, id替换感觉更加可靠。

TintProgressBar不变色,其余组件变色正常

下面是我的布局代码,机型是mi6 android版本是7.1
`
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:fresco="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.facebook.drawee.view.SimpleDraweeView
android:id="@+id/playbar_img"
android:layout_width="43dp"
android:layout_height="43dp"
android:layout_marginBottom="16dp"
android:layout_marginLeft="8dp"
android:layout_marginStart="8dp"
android:layout_weight="0"
fresco:layout_constraintBottom_toTopOf="@+id/guideline"
fresco:layout_constraintLeft_toLeftOf="parent"
fresco:placeholderImage="@mipmap/placeholder_disk_210"
fresco:placeholderImageScaleType="fitXY"/>


<com.bilibili.magicasakura.widgets.TintImageView
android:id="@+id/play_list"
android:layout_width="43dp"
android:layout_height="43dp"
android:layout_marginBottom="16dp"
android:layout_marginEnd="4dp"
android:layout_marginRight="4dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:onClick="click_last"
android:src="@mipmap/playbar_btn_playlist"
fresco:imageTint="@color/theme_color_primary"
fresco:layout_constraintBottom_toTopOf="@+id/guideline"
fresco:layout_constraintRight_toLeftOf="@+id/control"/>

<com.bilibili.magicasakura.widgets.TintImageView
    android:id="@+id/control"
    android:layout_width="41dp"
    android:layout_height="46dp"
    android:layout_marginBottom="16dp"
    android:layout_marginEnd="4dp"

    android:layout_marginRight="4dp"
    android:background="?attr/selectableItemBackgroundBorderless"
    android:src="@mipmap/playbar_btn_play"
    fresco:imageTint="@color/theme_color_primary"
    fresco:layout_constraintBottom_toTopOf="@+id/guideline"
    fresco:layout_constraintRight_toLeftOf="@+id/play_next"/>

<com.bilibili.magicasakura.widgets.TintImageView
    android:id="@+id/play_next"
    android:layout_width="43dp"
    android:layout_height="43dp"
    android:layout_marginBottom="16dp"
    android:layout_marginEnd="4dp"
    android:layout_marginRight="4dp"
    android:background="?attr/selectableItemBackgroundBorderless"
    android:onClick="click_next"
    android:src="@mipmap/playbar_btn_next"
    fresco:imageTint="@color/theme_color_primary"
    fresco:layout_constraintBottom_toTopOf="@+id/guideline"
    fresco:layout_constraintRight_toRightOf="parent"/>
<android.support.constraint.Guideline android:id="@+id/guideline"
                                      android:layout_width="wrap_content"
                                      android:layout_height="wrap_content"
                                      android:orientation="horizontal"
                                      fresco:layout_constraintGuide_begin="60dp"
/>
<com.bilibili.magicasakura.widgets.TintProgressBar
    android:id="@+id/song_progress_normal"
    style="@style/Widget.AppCompat.ProgressBar.Horizontal"
    android:layout_width="0dp"
    android:layout_height="10dp"
    android:layout_marginBottom="5dp"
    android:progress="0"
    android:max="100"
    app:layout_constraintBottom_toTopOf="@+id/guideline"
    app:layout_constraintHorizontal_bias="0.533"
    app:layout_constraintLeft_toLeftOf="parent"
    app:layout_constraintRight_toRightOf="parent"
    app:progressIndeterminateTint="@color/theme_color_primary"/>

</android.support.constraint.ConstraintLayout>`

这是我的项目地址:https://github.com/NightXlt/NetEaseMusic

error inflating TintWidget when running Robolectric unit test

Caused by: java.lang.NullPointerException at org.robolectric.android.XmlResourceParserImpl.getResourceId(XmlResourceParserImpl.java:789) at org.robolectric.android.XmlResourceParserImpl.getAttributeNameResource(XmlResourceParserImpl.java:596) at org.robolectric.shadows.ShadowAssetManager.findAttributeValue(ShadowAssetManager.java:823) at org.robolectric.shadows.ShadowAssetManager.buildTypedValue(ShadowAssetManager.java:747) at org.robolectric.shadows.ShadowAssetManager.attrsToTypedArray(ShadowAssetManager.java:795) at org.robolectric.shadows.ShadowResourcesImpl$ShadowThemeImpl.obtainStyledAttributes(ShadowResourcesImpl.java:177) at android.content.res.ResourcesImpl$ThemeImpl.obtainStyledAttributes(ResourcesImpl.java) at android.content.res.Resources$Theme.obtainStyledAttributes(Resources.java:1493) at android.content.Context.obtainStyledAttributes(Context.java:599) at com.bilibili.magicasakura.utils.ColorStateListUtils.inflateColorStateList(ColorStateListUtils.java:110) at com.bilibili.magicasakura.utils.ColorStateListUtils.createFromXmlInner(ColorStateListUtils.java:92) at com.bilibili.magicasakura.utils.ColorStateListUtils.createColorStateList(ColorStateListUtils.java:72) at com.bilibili.magicasakura.utils.TintManager.getColorStateList(TintManager.java:115) at com.bilibili.magicasakura.utils.DrawableUtils.getTintColorList(DrawableUtils.java:173) at com.bilibili.magicasakura.utils.RippleDrawableInflateImpl.inflateDrawable(RippleDrawableInflateImpl.java:41) at com.bilibili.magicasakura.utils.DrawableUtils.createFromXmlInner(DrawableUtils.java:107) at com.bilibili.magicasakura.utils.DrawableUtils.createDrawable(DrawableUtils.java:75) at com.bilibili.magicasakura.utils.TintManager.getDrawable(TintManager.java:146) at com.bilibili.magicasakura.widgets.AppCompatBackgroundHelper.loadFromAttribute(AppCompatBackgroundHelper.java:69) at com.bilibili.magicasakura.widgets.TintButton.<init>(TintButton.java:56) at com.bilibili.magicasakura.widgets.TintButton.<init>(TintButton.java:45) at android.view.LayoutInflater.createView(LayoutInflater.java:645) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:787) at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727) at android.view.LayoutInflater.rInflate(LayoutInflater.java:858) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.parseInclude(LayoutInflater.java:994) at android.view.LayoutInflater.rInflate(LayoutInflater.java:854) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.rInflate(LayoutInflater.java:861) at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821) at android.view.LayoutInflater.inflate(LayoutInflater.java:518) at android.view.LayoutInflater.inflate(LayoutInflater.java:426) at android.view.LayoutInflater.inflate(LayoutInflater.java:377) at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:288) at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:143) at com.ladddd.myandroidarch.ui.activity.MainActivity.initView(MainActivity.java:98)

缺少 TintTabLayout

有 android:background app:tabSelectedTextColor app:tabTextColor 三个属性需要替换。
另外 loadFromAttribute 方法不是 public ,扩展很不方便(我现在是把用到的 helper 和 base 都复制了一遍),有什么特别用意吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.