安卓吸顶效果

安卓吸顶效果_第1张图片当列表滑动时,图片逐渐消失,toolBar悬停在头部。



    

        


            

                

            

            

                

                

                


                

                    

                    
                

            
        

        


                


        


    

public class MainActivity extends AppCompatActivity {
    RecyclerView recyclerView;
    private List list;
    private NormalAdapter normalAdapter;
    private LinearLayoutManager linearLayoutManager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        recyclerView=findViewById(R.id.goodsRecyclerView);
        initList();
        initView();
    }

    private void initList() {
        list = new ArrayList<>();
        for (int i = 1; i <= 100; i++) {
            list.add(i + "");
        }
    }

    private void initView() {
        linearLayoutManager = new LinearLayoutManager(this);
        normalAdapter = new NormalAdapter(list);

        recyclerView.setLayoutManager(linearLayoutManager);
        recyclerView.setNestedScrollingEnabled(false);
        recyclerView.setAdapter(normalAdapter);
    }
}

demo地址

你可能感兴趣的:(android)