Design lib - CoordinatorLayout/CollapsingToolbarLayout with GridView/listView

前端 未结 6 1219
别跟我提以往
别跟我提以往 2020-11-30 07:54

This might be silly question but I didn\'t understand Design lib well. I am following this reference to create below layout. The Blue area should work as parallax when I scr

6条回答
  •  被撕碎了的回忆
    2020-11-30 08:04

    For convenience i've created a subclass with the new ViewCompat solution:

    public class CoordinatedListView extends ListView {
    
        public CoordinatedListView(Context context) {
            super(context);
            init();
        }
    
        public CoordinatedListView(Context context, AttributeSet attrs) {
            super(context, attrs);
            init();
        }
    
        public CoordinatedListView(Context context, AttributeSet attrs, int defStyleAttr) {
            super(context, attrs, defStyleAttr);
            init();
        }
    
        @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
        public CoordinatedListView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
            super(context, attrs, defStyleAttr, defStyleRes);
            init();
        }
    
        private void init() {
            ViewCompat.setNestedScrollingEnabled(this, true);
        }
    }
    

    Enjoy :)

提交回复
热议问题