NestedScrollView,字节跳动算法工程师总结

         <!--   功能菜单     -->
        <LinearLayout
            android:id="@+id/ll_home_menu"
            android:layout_width="match_parent"
            android:layout_height="90dp"
            android:layout_marginHorizontal="16dp"
            android:layout_marginTop="10dp"
            android:orientation="horizontal">

            <LinearLayout
                android:id="@+id/ll_home_menu_reservation"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginEnd="16dp"
                android:layout_weight="1"
                android:background="@drawable/style_constraintlayout_purple_gradient_bg"
                android:gravity="center"
                android:orientation="vertical">

                <androidx.cardview.widget.CardView
                    android:id="@+id/cv_menu_home_reservation"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginHorizontal="6dp"
                    android:layout_marginTop="4dp"
                    app:cardCornerRadius="8dp"
                    app:cardElevation="0dp">

                    <ImageView
                        android:layout_width="60dp"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:scaleType="centerInside"
                        android:src="@drawable/home_menu_reservation" />
                </androidx.cardview.widget.CardView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="20dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="4dp"
                    android:gravity="center"
                    android:text="@string/homeMenuReservation"
                    android:textColor="@color/white" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_home_menu_group"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="16dp"
                android:layout_weight="1"
                android:background="@drawable/style_constraintlayout_blue_gradient_bg"
                android:gravity="center"
                android:orientation="vertical">

                <androidx.cardview.widget.CardView
                    android:id="@+id/cv_menu_home_group"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginHorizontal="6dp"
                    android:layout_marginTop="4dp"
                    app:cardCornerRadius="8dp"
                    app:cardElevation="0dp">

                    <ImageView
                        android:layout_width="60dp"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:scaleType="centerInside"
                        android:src="@drawable/home_menu_group" />
                </androidx.cardview.widget.CardView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="20dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="4dp"
                    android:gravity="center"
                    android:text="@string/homeMenuGroup"
                    android:textColor="@color/white" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_home_menu_unpack"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginStart="8dp"
                android:layout_marginEnd="16dp"
                android:layout_weight="1"
                android:background="@drawable/style_constraintlayout_orange_gradient_bg"
                android:gravity="center"
                android:orientation="vertical">

                <androidx.cardview.widget.CardView
                    android:id="@+id/cv_menu_home_unpack"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginHorizontal="6dp"
                    android:layout_marginTop="4dp"
                    app:cardCornerRadius="8dp"
                    app:cardElevation="0dp">

                    <ImageView
                        android:layout_width="60dp"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:scaleType="centerInside"
                        android:src="@drawable/home_menu_unpack" />
                </androidx.cardview.widget.CardView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="20dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="4dp"
                    android:gravity="center"
                    android:text="@string/homeMenuUnpack"
                    android:textColor="@color/white" />
            </LinearLayout>

            <LinearLayout
                android:id="@+id/ll_home_menu_game"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_marginStart="8dp"
                android:layout_weight="1"
                android:background="@drawable/style_constraintlayout_red_gradient_bg"
                android:gravity="center"
                android:orientation="vertical">

                <androidx.cardview.widget.CardView
                    android:id="@+id/cv_menu_home_game"
                    android:layout_width="match_parent"
                    android:layout_height="60dp"
                    android:layout_marginHorizontal="6dp"
                    android:layout_marginTop="4dp"
                    app:cardCornerRadius="8dp"
                    app:cardElevation="0dp">

                    <ImageView
                        android:layout_width="60dp"
                        android:layout_height="match_parent"
                        android:layout_gravity="center"
                        android:scaleType="centerInside"
                        android:src="@drawable/home_menu_game" />
                </androidx.cardview.widget.CardView>

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="20dp"
                    android:layout_marginTop="2dp"
                    android:layout_marginBottom="4dp"
                    android:gravity="center"
                    android:text="@string/homeMenuGame"
                    android:textColor="@color/white" />
            </LinearLayout>

            <TextView
                android:id="@+id/tv_home_menu_gourmet"
                android:layout_width="0dp"
                android:layout_height="match_parent"
                android:layout_weight="1"
                android:drawableTop="@mipmap/ic_home_menu_gourmet"
                android:drawablePadding="3dp"
                android:gravity="center"
                android:text="@string/homeMenuGourmet"
                android:visibility="gone" />
        </LinearLayout>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/lightGray"
            android:nestedScrollingEnabled="false"
            android:orientation="vertical">
            <!-- 秒杀 -->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_home_spike"
                android:layout_width="match_parent"
                android:layout_height="120dp"
                android:layout_marginHorizontal="16dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/style_linearlayout_round">

                <TextView
                    android:id="@+id/tv_home_spike"
                    android:layout_width="match_parent"
                    android:layout_height="30dp"
                    android:background="@drawable/style_textview_horizontal_gradient_round_top"
                    android:gravity="start|center_vertical"
                    android:paddingStart="16dp"
                    android:paddingEnd="10dp"
                    android:text="@string/homeSpike"
                    android:textColor="@color/white"
                    android:textSize="16sp"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <androidx.cardview.widget.CardView
                    android:id="@+id/cv_home_spike_img"
                    android:layout_width="80dp"
                    android:layout_height="80dp"
                    android:layout_gravity="center"
                    android:layout_marginStart="20dp"
                    app:cardCornerRadius="8dp"
                    app:cardElevation="0dp"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@id/ll_home_spike"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/tv_home_spike">

                    <ImageView
                        android:layout_width="match_parent"
                        android:layout_height="80dp"
                        android:src="@drawable/test_1" />
                </androidx.cardview.widget.CardView>

                <LinearLayout
                    android:id="@+id/ll_home_spike"
                    android:layout_width="0dp"
                    android:layout_height="60dp"
                    android:orientation="vertical"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_weight="1"
                    app:layout_constraintStart_toEndOf="@+id/cv_home_spike_img"
                    app:layout_constraintTop_toBottomOf="@id/tv_home_spike">

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:gravity="start|center_vertical"
                        android:paddingStart="20dp"
                        android:text="00000000"
                        android:textColor="@color/deepTextColor"
                        android:textSize="16sp" />

                    <TextView
                        android:layout_width="match_parent"
                        android:layout_height="30dp"
                        android:gravity="start|center_vertical"
                        android:paddingStart="20dp"
                        android:text="111111111111" />
                </LinearLayout>

                <TextView
                    android:id="@+id/tv_home_spike_discount_price"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:paddingStart="20dp"
                    android:text="¥99.00"
                    android:textColor="@color/crimson"
                    app:layout_constraintStart_toEndOf="@id/cv_home_spike_img"
                    app:layout_constraintTop_toBottomOf="@id/ll_home_spike" />

                <TextView
                    android:id="@+id/tv_home_spike_price"
                    android:layout_width="wrap_content"
                    android:layout_height="30dp"
                    android:gravity="start|center_vertical"
                    android:paddingStart="20dp"
                    android:text="¥199.00"
                    android:textColor="@color/grey"
                    app:layout_constraintStart_toEndOf="@id/tv_home_spike_discount_price"
                    app:layout_constraintTop_toBottomOf="@id/ll_home_spike" />

            </androidx.constraintlayout.widget.ConstraintLayout>
            <!-- 优惠券 -->
            <androidx.constraintlayout.widget.ConstraintLayout
                android:id="@+id/cl_home_coupon"
                android:layout_width="match_parent"
                android:layout_height="140dp"
                android:layout_marginHorizontal="16dp"
                android:layout_marginTop="10dp"
                android:background="@drawable/style_linearlayout_round">

                <TextView
                    android:id="@+id/tv_menu_home_coupon_list"
                    android:layout_width="match_parent"
                    android:layout_height="35dp"
                    android:background="@drawable/style_textview_horizontal_gradient_round_top"
                    android:gravity="start|center_vertical"
                    android:paddingStart="16dp"
                    android:text="@string/menuHomeCouponList"
                    android:textColor="@color/white"
                    android:textSize="16sp"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toTopOf="parent" />

                <TextView
                    android:id="@+id/tv_menu_home_coupon_seller1"
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="每满1000减100元"
                    android:textColor="@color/crimson"
                    app:layout_constraintBottom_toTopOf="@id/tv_menu_home_description1"
                    app:layout_constraintEnd_toStartOf="@id/tv_menu_home_coupon_seller2"
                    app:layout_constraintHorizontal_weight="1"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_coupon_list" />

                <TextView
                    android:id="@+id/tv_menu_home_description1"
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="仅可购买部分品类商品"
                    app:layout_constraintEnd_toStartOf="@id/tv_menu_home_description2"
                    app:layout_constraintHorizontal_weight="1"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_coupon_seller1" />

                <Button
                    android:id="@+id/btn_menu_home_coupon1"
                    android:layout_width="100dp"
                    android:layout_height="28dp"
                    android:layout_marginStart="40dp"
                    android:background="@drawable/style_coupon_button_round"
                    android:text="@string/menuHomeCouponReceive"
                    android:textColor="@color/crimson"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@id/tv_menu_home_coupon_dividing_line"
                    app:layout_constraintStart_toStartOf="parent"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_description1" />

                <TextView
                    android:id="@+id/tv_menu_home_coupon_dividing_line"
                    android:layout_width="100dp"
                    android:layout_height="100dp"
                    android:layout_marginHorizontal="-40dp"
                    android:background="@drawable/style_dividing_line_vertical"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toStartOf="@id/tv_menu_home_coupon_seller2"
                    app:layout_constraintStart_toEndOf="@id/tv_menu_home_coupon_seller1"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_coupon_list" />

                <TextView
                    android:id="@+id/tv_menu_home_coupon_seller2"
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="每满1000减100元"
                    android:textColor="@color/crimson"
                    app:layout_constraintBottom_toTopOf="@id/tv_menu_home_description2"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_weight="1"
                    app:layout_constraintStart_toEndOf="@id/tv_menu_home_coupon_seller1"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_coupon_list" />

                <TextView
                    android:id="@+id/tv_menu_home_description2"
                    android:layout_width="0dp"
                    android:layout_height="30dp"
                    android:gravity="center"
                    android:text="仅可购买部分品类商品"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintHorizontal_weight="1"
                    app:layout_constraintStart_toEndOf="@id/tv_menu_home_description1"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_coupon_seller2" />

                <Button
                    android:id="@+id/btn_menu_home_coupon2"
                    android:layout_width="100dp"
                    android:layout_height="28dp"
                    android:layout_marginEnd="40dp"
                    android:background="@drawable/style_coupon_button_round"
                    android:text="@string/menuHomeCouponReceive"
                    android:textColor="@color/crimson"
                    app:layout_constraintBottom_toBottomOf="parent"
                    app:layout_constraintEnd_toEndOf="parent"
                    app:layout_constraintStart_toEndOf="@id/tv_menu_home_coupon_dividing_line"
                    app:layout_constraintTop_toBottomOf="@id/tv_menu_home_description2" />

            </androidx.constraintlayout.widget.ConstraintLayout>
            <!-- 瀑布流 -->
            <androidx.recyclerview.widget.RecyclerView
                android:id="@+id/rv_water_falls_flow"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginHorizontal="16dp"
                android:layout_marginTop="10dp" />
        </LinearLayout>
    </LinearLayout>
</androidx.core.widget.NestedScrollView>
```

Fragment:同样请忽略无用逻辑

package com.qingnuo.yami.view.home;

import android.content.Context;
import android.content.Intent;
import android.database.Observable;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ObservableField;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.youth.banner.adapter.BannerImageAdapter;
import com.youth.banner.holder.BannerImageHolder;
import com.youth.banner.indicator.CircleIndicator;

import java.util.ArrayList;
import java.util.List;

/**
 * 首页横向菜单首页
 */
public class HomeMenuFragment extends Fragment implements View.OnClickListener {
    private static final String TAG = "HomeMenuFragment";
    private FragmentMenuHomeBinding menuHomeBinding;
    private Context mContext;


    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        menuHomeBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_menu_home, container, false);
        mContext = getContext();
        initView();
        return menuHomeBinding.getRoot();
    }

    private void initView() {

        //设置Adapter
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值