每日记录自己的Android项目(一)

news2024/9/21 18:54:46

Jetpack之Navigation

今天新创建一个项目,选的是这个。

首先映入眼帘的是一个这样的界面。

由ViewBinding绑定好XML布局和根布局和标题栏。

这个应该是Navigationg里面的内容

还有个字段

private AppBarConfiguration appBarConfiguration;

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        binding = ActivityMainBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        setSupportActionBar(binding.toolbar);

        NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment_content_main);
        appBarConfiguration = new AppBarConfiguration.Builder(navController.getGraph()).build();
        NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);

        binding.fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });
    }

这个是右下角的一个FloatingActionButton。点击就会像Toast一样弹出一个东西出来。

binding.fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

这两个是绑定选项菜单的。

 @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

然后进去FragmentA后发现这是一个主Activity嵌入两个子Fragment的页面,主Activity主要写了一个Toolbar和绑定了菜单和浮动按钮和绑定布局,两个Fragment写了自己的布局。


然后还有一个在res里面的Navigation文件夹,里面写了一个Fragment跳转的文件,居然可以分开,耦合度降低了,但是这个文件需要用一个Fragment来作为容器进行跳转。

容器通过 app:navGraph="@navigation/nav_graph" 和Navigation相关联。

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior">

    <fragment
        android:id="@+id/nav_host_fragment_content_main"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="0dp"
        android:layout_height="0dp"
        app:defaultNavHost="true"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:navGraph="@navigation/nav_graph" />
</androidx.constraintlayout.widget.ConstraintLayout>

根布局的ID是给XML绑定的,而fragment的id是给UI元素触发点击事件绑定的。

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/nav_graph"
    app:startDestination="@id/FirstFragment">

    <fragment
        android:id="@+id/FirstFragment"
        android:name="com.example.myapplication.FirstFragment"
        android:label="@string/first_fragment_label"
        tools:layout="@layout/fragment_first">

        <action
            android:id="@+id/action_FirstFragment_to_SecondFragment"
            app:destination="@id/SecondFragment" />
    </fragment>
    <fragment
        android:id="@+id/SecondFragment"
        android:name="com.example.myapplication.SecondFragment"
        android:label="@string/second_fragment_label"
        tools:layout="@layout/fragment_second">

        <action
            android:id="@+id/action_SecondFragment_to_FirstFragment"
            app:destination="@id/FirstFragment" />
    </fragment>
</navigation>

然后在Activity中绑定并初始化容器XML即可。

在FragmentA中,怎么通过按钮跳转呢?

public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        binding.buttonFirst.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NavHostFragment.findNavController(FirstFragment.this)
                        .navigate(R.id.action_FirstFragment_to_SecondFragment);
            }
        });
    }

FragmentB也是差不多的。

 public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        binding.buttonSecond.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NavHostFragment.findNavController(SecondFragment.this)
                        .navigate(R.id.action_SecondFragment_to_FirstFragment);
            }
        });

贴上其中一个Fragment的代码

package com.example.myapplication;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.navigation.fragment.NavHostFragment;

import com.example.myapplication.databinding.FragmentFirstBinding;

public class FirstFragment extends Fragment {

    private FragmentFirstBinding binding;

    @Override
    public View onCreateView(
            LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState
    ) {

        binding = FragmentFirstBinding.inflate(inflater, container, false);
        return binding.getRoot();

    }

    public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        binding.buttonFirst.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                NavHostFragment.findNavController(FirstFragment.this)
                        .navigate(R.id.action_FirstFragment_to_SecondFragment);
            }
        });
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        binding = null;
    }

}

自定义按钮

(背景有点歪了)

<Button
    android:id="@+id/button_first"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:text="@string/title"
    android:textSize="20dp"
    android:textColor="@color/blue"
    android:background="@drawable/loading_btn"
    android:layout_margin="28dp"
    app:layout_constraintBottom_toBottomOf="parent"
    app:layout_constraintEnd_toEndOf="parent"
    app:layout_constraintStart_toStartOf="parent"
    app:layout_constraintTop_toBottomOf="@id/textview_first" />

对于button的背景重新设定了一下,因为我需要有圆弧的

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">

    <solid android:color="@color/white"/>

    <corners android:radius="100dp"/>

</shape>


自定义标题栏

因为我想让标题栏的文字居中,但toolbar好像没有提供这个功能,所以我在toolbar里面嵌入一个文字,直接让文字居中

 <androidx.appcompat.widget.Toolbar
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?attr/actionBarSize"
        android:background="@color/ivory"
        >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="@string/title"
        android:layout_gravity="center"
        android:textSize="20dp"
        android:textColor="@color/black"/>

</androidx.appcompat.widget.Toolbar>


添加菜单

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);
    return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();
    switch (id) {
        case R.id.action_settings://弹出窗
            //实例化并去掉背景
            dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
            dialog.setContentView(R.layout.buttom_menu_dialog);
            dialog.show();
            Toast.makeText(this, "111", Toast.LENGTH_SHORT).show();
            return true;
        default:
            break;
    }
    return super.onOptionsItemSelected(item);
}

点击菜单显示弹窗

dialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
dialog.setContentView(R.layout.buttom_menu_dialog);
dialog.show();

构造参数第二个参数是把背景去掉,为什么要把背景去掉呢?

因为我想要背景有半径。

以下是R.style.BottomSheetDialog,去掉背景的。

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <style name="BottomSheetDialog" parent="Theme.Design.Light.BottomSheetDialog">
        <item name="bottomSheetStyle">@style/bottomSheetStyleWrapper</item>
    </style>
    <style name="bottomSheetStyleWrapper" parent="Widget.Design.BottomSheet.Modal">
        <item name="android:background">@android:color/transparent</item>
    </style>
</resources>

第二句话是设置一个布局。

怎么重新设置一个有半径的背景呢?

在根布局中设置background即可。

shape在res\drawable中创建。背景的格式什么呀都在这里创建。

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <!-- rectangle表示为矩形 -->

    <!-- 填充的颜色 -->
    <solid android:color="@color/white" />

    <!-- 边框的颜色和粗细 -->
    <stroke
        android:width="1dp"
        android:color="@color/white" />

    <!-- android:radius 关键点,圆角的半径 -->
    <corners
        android:topLeftRadius="25dp"
        android:topRightRadius="25dp"
        android:bottomRightRadius="0dp"
        android:bottomLeftRadius="0dp" />

</shape>

然后放到最外层的LinearLayout中。

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="bottom"
    android:background="@drawable/menu_corner_background"
    android:orientation="vertical">
    <!--    背景边缘化半径-->

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="30dp"
            android:layout_margin="20dp"
            android:text="导航菜单"
            android:textSize="20dp"
            android:textColor="@color/black"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/title_close"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginEnd="24dp"
            android:background="@null"
            android:text="关闭"
            android:textColor="@color/gray"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintVertical_bias="0.509" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="#C8C2C2" />

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="190dp"
        android:orientation="horizontal">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_marginStart="10dp">

            <ImageView
                android:id="@+id/about"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_margin="20dp"
                android:src="@mipmap/menu"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.533"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="关于"
                android:textColor="@color/black"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/about" />
        </androidx.constraintlayout.widget.ConstraintLayout>


        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/report"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_margin="20dp"
                android:src="@mipmap/menu"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.533"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="投诉"
                android:textColor="@color/black"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/report" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <ImageView
                android:id="@+id/Settled"
                android:layout_width="40dp"
                android:layout_height="40dp"
                android:layout_margin="20dp"
                android:src="@mipmap/menu"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.533"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="8dp"
                android:text="入驻"
                android:textColor="@color/black"
                app:layout_constraintBottom_toBottomOf="parent"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@+id/Settled" />
        </androidx.constraintlayout.widget.ConstraintLayout>

    </LinearLayout>

</LinearLayout>


沉浸式状态栏

一开始我用的是这个依赖里面的StatusBarUtil类。

implementation 'com.jaeger.statusbarutil:library:1.5.1'

但是我发现Sycn完,这个类也没有显示,也没有导包的选项,好TM奇怪啊。

后面发现JCenter远程仓库已经宣布停止维护了,而该事件造成的影响主要表现为: 2022 年 2 月 1 日之后 Android Studio 将无法从 JCenter 仓库拉取任何代码库,统统都会拉取失败,间接导致项目无法编译通过,所以好像就下不了了。。

里面有这个库的看这里更换。

所以怎么办呢?我就去Github找,找了一个收藏最多的的GitHub项目。这个GitHub项目挺不错的。

首先现在app模块添加依赖。

implementation 'com.geyifeng.immersionbar:immersionbar:3.2.2'

随后在Java代码中

 //沉浸式状态栏
ImmersionBar.with(this)
        //使用该属性,必须指定状态栏颜色,让状态栏变成和toolbar一样颜色
        .fitsSystemWindows(true).statusBarColor(R.color.ivory)
        //设置状态栏字体颜色为黑色
        .statusBarDarkFont(true, 0.2f).init();

思路:把状态栏全程变成白色,就会自动获取状态栏高度然后设置上去,不然状态栏和标题栏重合。

然后把状态栏的图标变成黑色就可以了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/383783.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

C# 序列化时“检测到循环引用”错误的彻底解决方案

目录 一&#xff0c;问题表现 二、没有技术含量的解决方案 三、本人彻底的解决方案 简要说明 贴代码 思路解析 思路 一&#xff0c;问题表现 示例代码如下&#xff1a; [Serializable] public class NodeTest {public NodeTest (){new List<NodeTest> ();}p…

SpringBoot之@ConfigurationProperties、@EnableConfigurationProperties

ConfigurationProperties 这个注解不仅可以为yml某个类注入还可以为第三方bean绑定属性 为yml某个类注入 只要将对应的yml类对象声明实体pojo并交给spring容器管理&#xff0c;再在类上使用ConfigurationProperties绑定对应的类名即可 涉及到两个知识点&#xff0c;这个类对…

C语言中的数据储存规则

写在开头 关于复习的相关内容其实从一开始就列出了大纲&#xff0c;但是迟迟没有开始复习&#xff0c;一方面是因为学校学业却是繁忙&#xff0c;另一方面还是内心对旧知识掌握不熟练需要再学一遍的畏惧和懒惰&#xff0c;但如今&#xff0c;复习必须开始了。今天我从C语言的最…

Linux/MacOS 生成双击可执行文件

双击可执行文件包含两种&#xff1a;终端shell脚本 Unix可执行文件 1.终端shell脚本 随意新建一个文件&#xff08;可使用command键N&#xff0c;前提是有已打开的文件&#xff09;&#xff0c;输入shell格式的测试代码&#xff0c;比如&#xff1a; #! /bin/sh echo “h…

双喜临门|炼石荣获2023年中国网络和数据安全高峰论坛双奖项

2023年2月23日-24日&#xff0c;工业和信息化部、四川省人民政府联合主办以“新征程 新思路 高质量发展”为主题的“2023年中国网络和数据安全产业高峰论坛”在成都隆重召开。工信安全中心第一届网络安全高成长性企业“勇攀之星”正式揭晓&#xff0c;炼石以高成长性、高创新性…

【vue】iframe相关问题

一、刷新iframe页面iframe的地址没有改变的话&#xff0c;每打开一次iframe页面&#xff0c;都不会主动更新页面的。以下有几种方法&#xff0c;都可以实现&#xff0c;每打开一次页面&#xff0c;就刷新一下给iframe添加key<template><div id"Iframe">&…

一名IC验证工程师的成长路径是怎么样的?来听听工程师的见解

IC验证这个岗位对于非科班的学生是比较友好的&#xff0c;因为验证需要具备的技能UVM&#xff0c;SV&#xff0c;C等&#xff0c;非科班和科班的差距不会拉开太大。因其岗位需求量巨大而格外受到了大家的青睐&#xff0c;甚至成为不少学生的转行首选。 验证对于IC的重要性 IC…

汽车 12V 和 24V 电池输入保护推荐

简介汽车电池电源线路在运行系统时容易出现瞬变。所需的典型保护包括过压、过载、反极性和跨接启动。在汽车 的生命周期中&#xff0c;交流发电机可能会被更换为非OEM 部件。售后市场上的交流发电机可能具有不同的负载突降&#xff08;LOAD DUMP&#xff09;保护或没有负载突降…

论文阅读-Attention Bottlenecks for Multimodal Fusion(多模态特征融合)

一、论文信息 论文题目&#xff1a;Attention Bottlenecks for Multimodal Fusion paperwithcode&#xff1a;https://paperswithcode.com/paper/attention-bottlenecks-for-multimodal-fusion Github&#xff1a;https://github.com/google-research/scenic/tree/main/scen…

产品故事:语雀两度生死局

语雀是一款文档和知识库产品&#xff0c;2016 年从一个技术团队支付宝体验技术部生长出来&#xff0c;2021 年蚂蚁成立了智能协同事业部&#xff0c;重点产品即为语雀&#xff0c;以独立 BU 运作&#xff0c;算是完成了“成人礼”。我们和玉伯聊了聊语雀的成长故事。 极客时间&…

C++基础知识【3】控制语句

目录 前言 一、条件语句 1.1、if 语句 1.2、if-else 语句 1.3、switch 语句 二、循环语句 2.1、while 循环 2.2、do-while 循环 2.3、for 循环 三、跳转语句 3.1、break语句 3.2、continue语句 3.3、goto语句 四、一些新特性 4.1、if 语句和 switch 语句…

【数据结构与算法】图遍历算法 ( 深度优先搜索代码示例 )

文章目录一、深度优先搜索算法二、完整代码示例完整代码示例执行结果一、深度优先搜索算法 深度优先搜索算法步骤 : 将 深度优先搜索 算法步骤 转为代码 ; ① 访问初始结点 : 访问 初始结点 v , 并将该 初始结点 v 标记为 " 已访问 " ; 设置一个 访问标记 数组 , 数…

《C++ Primer》 第九章 顺序容器

《C Primer》 第九章 顺序容器 9.1 顺序容器概述 容器&#xff1a;特定类型对象的集合 顺序容器类型 vector 可变大小数组&#xff0c;支持快速随机访问&#xff0c;在尾部之外的位置插入或删除元素可能很慢deque 双端队列。支持快速随机访问。在头尾位置插入/删除速度很快…

【2022-09-14】米哈游秋招笔试三道编程题

第一题&#xff1a;最短子串 题目描述 米小游拿到了一个字符串&#xff0c;她想截取一个连续子串&#xff0c;使得该子串中包含至少k个连续的“mihoyo”。 你可以帮米小游求出最短的子串长度&#xff0c;以及对应的子串位置吗&#xff1f; 输入描述 第一行输入两个正整数n…

产品父子流程技术方案设计

产品父子流程技术方案设计 一、整体设计 根据业务需求分析&#xff0c;产品涉及法人代表及实控人风控决策流程调用&#xff0c;旨在降低风险&#xff0c;提高行内线上贷款业务风险决策的能力。 二、业务流程 1.业务流程图 2.交易流程 在授信交易切面入口处对法人代表及实控…

Spark性能优化三 checkpoint

&#xff08;一&#xff09;checkpoint介绍 checkpoint&#xff0c;是Spark提供的一个比较高级的功能。有时候&#xff0c;我们的Spark任务&#xff0c;比较复杂&#xff0c;从初始化RDD开始&#xff0c;到最后整个任务完成&#xff0c;有比较多的步骤&#xff0c;比如超过10个…

关于flex盒子padding-right/margin-right不生效

错误代码实例&#xff1a; <!DOCTYPE html> <html lang"en"><head><meta charset"UTF-8"><meta http-equiv"X-UA-Compatible" content"IEedge"><meta name"viewport" content"width…

论文投稿指南——中文核心期刊推荐(科学、科学研究)

【前言】 &#x1f680; 想发论文怎么办&#xff1f;手把手教你论文如何投稿&#xff01;那么&#xff0c;首先要搞懂投稿目标——论文期刊 &#x1f384; 在期刊论文的分布中&#xff0c;存在一种普遍现象&#xff1a;即对于某一特定的学科或专业来说&#xff0c;少数期刊所含…

element input 输入框校验

element input 输入框校验 很久之前有写过一篇&#xff1a;element 输入框只可以输入正整数 在这里对它进行补充 校验input输入框是否符合 以下是常用的一些&#xff1a; 限制输入中文&#xff1a;/^[\u4e00-\u9fa5]$/ const checkName (rule, value, callback) > {if…

逆约瑟夫问题

约瑟夫问题可以说十分经典&#xff0c;其没有公式解也是广为人知的~ 目录 前言 一、约瑟夫问题与逆约瑟夫问题 1.约瑟夫问题 2.逆约瑟夫问题 二、思考与尝试&#xff08;显然有很多失败&#xff09; 问题分析 尝试一&#xff1a;递归/递推的尝试 尝试二&#xff1a;条件…