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 &