CoordinatorLayout 的简单使用,一文详解
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res
《Android 学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》
【docs.qq.com/doc/DSkNLaERkbnFoS0ZF】 完整内容开源分享
/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#f00"
android:minHeight="25dp"
app:layout_scrollFlags="scroll"/>
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="#0f0"/>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_my_test"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
要点剖析??
CoordinatorLayout 作为根布局
AppBarLayout 包括子布局 其中子布局可以添加?app:layout_scrollFlags="" 属性来控制动画,属性值有如下五种,大家自行尝试
scroll
scroll|enterAlways
scroll|enterAlways|enterAlwaysCollapsed //与 android:minHeight="25dp"搭配使用
scroll|exitUntilCollapsed //与 android:minHeight="25dp"搭配使用
scroll|snap //要么开,要么关
?结合?RecyclerView 使用;ListView 不行
app:layout_behavior="@string/appbar_scrolling_view_behavior"这个属性不能掉,这是系统自带的?behavior,后期我会教大家写?behavior。CoordinatorLayout原理的简析
RecyclerView 的写法
package com.wust.selfcoordinatorlayout;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
private RecyclerView rv_my_test;
private MyAdapter mAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
rv_my_test = findViewById(R.id.rv_my_test);
mAdapter = new MyAdapter();
RecyclerView.LayoutManager lm = new LinearLayoutManager(this);
rv_my_test.setLayoutManager(lm);
rv_my_test.setAdapter(mAdapter);
}
private class MyAdapter extends RecyclerView.Adapter{
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
最后
希望大家能有一个好心态,想进什么样的公司要想清楚,并不一定是大公司,我选的也不是特大厂。当然如果你不知道选或是没有规划,那就选大公司!希望我们能先选好想去的公司再投或内推,而不是有一个公司要我我就去!还有就是不要害怕,也不要有压力,平常心对待就行,但准备要充足。最后希望大家都能拿到一份满意的 offer !如果目前有一份工作也请好好珍惜好好努力,找工作其实挺累挺辛苦的。
这里附上上述的面试题相关的几十套字节跳动,京东,小米,腾讯、头条、阿里、美团等公司 19 年的面试题。把技术点整理成了视频和 PDF(实际上比预期多花了不少精力),包含知识脉络 + 诸多细节。
由于篇幅有限,这里以图片的形式给大家展示一小部分。











评论