Android8.1 SystemUI QSCustomizer布局调整

本文介绍了如何调整Android8.1 SystemUI的QSCustomizer布局,包括修改背景颜色、改变tile显示的列数以及自定义ToolBar。通过修改源代码和布局文件,实现了个性化定制快速设置面板。
摘要由CSDN通过智能技术生成

Android8.1 SystemUI QSCustomizer布局调整

Google如果发现有些手机厂商有比较好的功能,就会在新版本中添加进来,我觉得 这个QSCustomizer就是属于这类
QSCustomizer就是下拉状态栏中快速设置按钮,支持手机用户自己修改。
这里用了RecyclerView,RecyclerView我没怎么用过,所以很多方法都不知道,碰到了困难还是求助同事才解决

./src/com/android/systemui/qs/customize/QSCustomizer.java
本次的修改都是围绕这个类。

1:修改背景颜色

首先找到了布局
./res/layout/qs_customize_panel.xml

<com.android.systemui.qs.customize.QSCustomizer
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:orientation="vertical"
    android:background="@drawable/qs_customizer_background"
    android:gravity="center_horizontal">

</com.android.systemui.qs.customize.QSCustomizer>

我这里直接修改了background,但是运行后发现,颜色只修改了上面的一半,下面的没变,最后在代码中(adapter)发现了一个Drawable,注释一下,果然生效
./src/com/android/systemui/qs/customize/TileAdapter.java

 private final SpanSizeLookup mSizeLookup = new SpanSizeLookup() {
        @Override
        public int getSpanSize(int position) {
            final int type = getItemViewType(position);
            return type == TYPE_EDIT || type == TYPE_DIVIDER ? 5 : 1;
        }
    };

    private class TileItemDecoration extends ItemDecoration {
   
//        private final ColorDrawable mDrawable;

        private TileItemDecoration(Context context) {
//            TypedArray ta =
//                    context.obtainStyledAttributes(new int[]{android.R.attr.colorSecondary});
//            mDrawable = new ColorDrawable(ta.getColor(0, 0));
//            ta.recycle();
        }


        @Override
        public void onDraw(Canvas c, RecyclerView parent, State state) {
            super.onDraw(c, parent, state);

            final int childCount = parent.getChildCount();
            final int width &
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值