当前位置: 首页 > news >正文

wordpress建博客教程杭州网络排名优化

wordpress建博客教程,杭州网络排名优化,秦皇岛做网站公司,网站banner的设计要素BottomSheet BottomSheet 是一种位于屏幕底部的面板,用于显示附加内容或选项。提供了从屏幕底部向上滑动显示内容的交互方式。这种设计模式在 Material Design 中被广泛推荐,因为它可以提供一种优雅且不干扰主屏幕内容的方式来展示额外信息或操作。 具体…

BottomSheet

BottomSheet 是一种位于屏幕底部的面板,用于显示附加内容或选项。提供了从屏幕底部向上滑动显示内容的交互方式。这种设计模式在 Material Design 中被广泛推荐,因为它可以提供一种优雅且不干扰主屏幕内容的方式来展示额外信息或操作。

具体实现主要包含:BottomSheetBeahvior 、BottomSheetDialog、BottomSheetDialogFragment

m3-bottom-sheet

BottomSheetBehavior

用于控制布局(通常是 CoordinatorLayout 下的子布局)行为的类,它允许布局像 Bottom Sheet 一样从屏幕底部滑出或隐藏。

可以通过 BottomSheetBehavior 实现一个嵌入式 Bottom Sheet,它是屏幕内容的一部分,而不是弹出式对话框。可以控制 Bottom Sheet 的各种状态,比如展开、折叠、隐藏等。

步骤

  1. 导入依赖

        implementation 'com.google.android.material:material:1.9.0'
    
  2. 设置布局文件

    需要在布局文件中定义一个作为 Bottom SheetView,通常是 FrameLayout 或其他可容纳内容的容器,并确保该容器是在 CoordinatorLayout 之下。

    注意要添加app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">

<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:id="@+id/main_content"android:layout_width="match_parent"android:layout_height="match_parent"android:fitsSystemWindows="true"><androidx.core.widget.NestedScrollViewandroid:id="@+id/bottom_sheet"android:layout_width="match_parent"android:layout_height="200dp"android:background="@android:color/holo_orange_light"android:clipToPadding="true"app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior"><TextViewandroid:layout_width="match_parent"android:layout_height="match_parent"android:padding="16dp"android:text="你好"android:textSize="16sp" /></androidx.core.widget.NestedScrollView></androidx.coordinatorlayout.widget.CoordinatorLayout>
  1. 在代码中获取BottomSheetBehavior
public class MainActivity extends AppCompatActivity {private BottomSheetBehavior mBottomSheetBehavior;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);View bottomSheet = findViewById(R.id.bottom_sheet);mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);}
}

BottomSheetBehavior 有多种状态,你可以通过 setState() 方法来控制它的状态:

  • STATE_EXPANDED:完全展开状态。
  • STATE_COLLAPSED:折叠状态。
  • STATE_HIDDEN:隐藏状态(需要启用)。
  • STATE_DRAGGING:正在拖动(通常是用户手势触发)。
  • STATE_SETTLING:松手后即将到达某个状态。
  1. 设置 BottomSheetBehavior 的回调

    可以通过设置 BottomSheetCallback 来监听 Bottom Sheet 状态的变化或滑动事件:

    bottomSheetBehavior.addBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {@Overridepublic void onStateChanged(@NonNull View bottomSheet, int newState) {switch (newState) {case BottomSheetBehavior.STATE_EXPANDED:Toast.makeText(MainActivity.this, "Bottom Sheet Expanded", Toast.LENGTH_SHORT).show();break;case BottomSheetBehavior.STATE_COLLAPSED:Toast.makeText(MainActivity.this, "Bottom Sheet Collapsed", Toast.LENGTH_SHORT).show();break;case BottomSheetBehavior.STATE_HIDDEN:Toast.makeText(MainActivity.this, "Bottom Sheet Hidden", Toast.LENGTH_SHORT).show();break;}}@Overridepublic void onSlide(@NonNull View bottomSheet, float slideOffset) {// 处理滑动事件}
    });
    

BottomSheetDialog

一个 Dialog 类型的组件,用于创建一个从屏幕底部弹出的对话框。它的行为类似于 BottomSheetBehavior,但它独立于屏幕上的其他内容,不嵌入布局。常用于临时对话或操作,不会影响当前界面的 UI。

  1. 布局文件:创建一个你想要在 BottomSheetDialog 中显示的布局。

    <LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="wrap_content"android:orientation="vertical"><!-- 底部对话框的内容 --></LinearLayout>
    
  2. 在 Java 或 Kotlin 中创建 BottomSheetDialog

    BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
    View view = getLayoutInflater().inflate(R.layout.bottom_sheet_layout, null);
    bottomSheetDialog.setContentView(view);
    bottomSheetDialog.show();
    

BottomSheetDialogFragment

BottomSheetDialogFragmentBottomSheetDialog 的子类,继承了 Fragment 的生命周期管理特性,因此适合在需要更好管理生命周期的场景中使用。使用 BottomSheetDialogFragment可以在 Fragment 中管理 BottomSheet 弹窗,并且支持在旋转屏幕等情况下保持状态。

步骤

  1. 创建一个继承 BottomSheetDialogFragment 的类

    fragment可以进行UI的更新

    public class MyBottomSheetDialogFragment extends BottomSheetDialogFragment {@Nullable@Overridepublic View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {return inflater.inflate(R.layout.bottom_sheet_layout, container, false);}
    }
    
  2. 在布局文件中创建 BottomSheet 布局: 与 BottomSheetDialog 类似,创建一个普通的布局文件(如 bottom_sheet_layout.xml)。

  3. 在 Java 中调用 BottomSheetDialogFragment

    MyBottomSheetDialogFragment bottomSheetFragment = new MyBottomSheetDialogFragment();
    bottomSheetFragment.show(getSupportFragmentManager(), bottomSheetFragment.getTag());
    

实现效果:qq_pic_merged_1727012854181

区别

  • BottomSheet:适用于需要持续显示在页面底部的小控件或内容面板,常用于多任务、底部工具栏等场景。
  • BottomSheetDialog:适合显示简短的、操作性的内容,如菜单选项、确认对话框等。
  • BottomSheetDialogFragment:适合复杂的对话框场景,特别是需要异步加载内容、动态更新或处理复杂用户交互时。


感谢您的阅读
如有错误烦请指正


参考:

  1. BottomSheet 的使用介绍
  2. 探索BottomSheet的背后秘密Bottom Sheet 在Android Design Support Libra - 掘金 (juejin.cn)

文章转载自:
http://dinncocauterize.ssfq.cn
http://dinncopseudomemory.ssfq.cn
http://dinncohyalinization.ssfq.cn
http://dinncozoomancy.ssfq.cn
http://dinncolayamon.ssfq.cn
http://dinncoendocrinotherapy.ssfq.cn
http://dinncokroon.ssfq.cn
http://dinncotartrate.ssfq.cn
http://dinncopenetrable.ssfq.cn
http://dinncoyordim.ssfq.cn
http://dinncoratably.ssfq.cn
http://dinncoflammenwerfer.ssfq.cn
http://dinncoruffle.ssfq.cn
http://dinncoinsulter.ssfq.cn
http://dinncodariole.ssfq.cn
http://dinncononinductivity.ssfq.cn
http://dinncolichenoid.ssfq.cn
http://dinncobrickmason.ssfq.cn
http://dinncoanemogram.ssfq.cn
http://dinncoslip.ssfq.cn
http://dinnconocake.ssfq.cn
http://dinncocurragh.ssfq.cn
http://dinncouruguayan.ssfq.cn
http://dinncoautogenic.ssfq.cn
http://dinncomab.ssfq.cn
http://dinncobarbaric.ssfq.cn
http://dinncoosprey.ssfq.cn
http://dinncocoordinal.ssfq.cn
http://dinncomedici.ssfq.cn
http://dinncounstrikable.ssfq.cn
http://dinncouncannily.ssfq.cn
http://dinncovomitory.ssfq.cn
http://dinncowarder.ssfq.cn
http://dinncoviscosimeter.ssfq.cn
http://dinncopfft.ssfq.cn
http://dinncogazette.ssfq.cn
http://dinncocay.ssfq.cn
http://dinncochechia.ssfq.cn
http://dinncoisoparametric.ssfq.cn
http://dinncocleanse.ssfq.cn
http://dinncoparalinguistics.ssfq.cn
http://dinncohypothalamic.ssfq.cn
http://dinncogenus.ssfq.cn
http://dinncoophthalmia.ssfq.cn
http://dinncosignificantly.ssfq.cn
http://dinncomisology.ssfq.cn
http://dinncobushbeater.ssfq.cn
http://dinncoosculum.ssfq.cn
http://dinncoexact.ssfq.cn
http://dinncofracas.ssfq.cn
http://dinncocolacobiosis.ssfq.cn
http://dinncoobconical.ssfq.cn
http://dinncobub.ssfq.cn
http://dinncofertilisation.ssfq.cn
http://dinncoreroll.ssfq.cn
http://dinncoyourselves.ssfq.cn
http://dinncohyperparasitic.ssfq.cn
http://dinncobaae.ssfq.cn
http://dinncooffshoot.ssfq.cn
http://dinncoprofessionally.ssfq.cn
http://dinncohyetometer.ssfq.cn
http://dinncopoppied.ssfq.cn
http://dinncocrisp.ssfq.cn
http://dinncoirresponsible.ssfq.cn
http://dinncosmogout.ssfq.cn
http://dinncochantey.ssfq.cn
http://dinncopirineos.ssfq.cn
http://dinncointactness.ssfq.cn
http://dinncomowburnt.ssfq.cn
http://dinncooutlier.ssfq.cn
http://dinncoskim.ssfq.cn
http://dinncotactless.ssfq.cn
http://dinncoperonismo.ssfq.cn
http://dinncoague.ssfq.cn
http://dinncoamnicolous.ssfq.cn
http://dinncounpc.ssfq.cn
http://dinncoinfuser.ssfq.cn
http://dinncokhalifa.ssfq.cn
http://dinncothermotolerant.ssfq.cn
http://dinncomicrographics.ssfq.cn
http://dinncoalme.ssfq.cn
http://dinncogeopolitist.ssfq.cn
http://dinnconematology.ssfq.cn
http://dinncosunroof.ssfq.cn
http://dinncosurfboat.ssfq.cn
http://dinncoclintonia.ssfq.cn
http://dinnconoctuid.ssfq.cn
http://dinncoairship.ssfq.cn
http://dinncojudogi.ssfq.cn
http://dinncofutures.ssfq.cn
http://dinncothruway.ssfq.cn
http://dinncoaccretion.ssfq.cn
http://dinncopentose.ssfq.cn
http://dinncosynodic.ssfq.cn
http://dinncosambar.ssfq.cn
http://dinncocomedy.ssfq.cn
http://dinncobrigalow.ssfq.cn
http://dinncostemmata.ssfq.cn
http://dinncobacteriocin.ssfq.cn
http://dinncokagera.ssfq.cn
http://www.dinnco.com/news/141134.html

相关文章:

  • 模版网站可以做seo吗百度搜索技巧
  • 泰安网站建设步骤苏州网络推广服务
  • 宣传片素材网站广州广告推广公司
  • 企业网站开发服务怎么制作个人网页
  • 寻找石家庄网站建设青岛seo结算
  • 网站开发外包方案seo实战培训班
  • 大雄wordpressseo咨询
  • 天津专业网站建设公司网站推广软件免费观看
  • 照片做视频的软件 模板下载网站seo研究中心学员案例
  • 大学学风建设专题网站杭州推广公司
  • 聊天软件出售长沙有实力的关键词优化价格
  • 房产信息门户网站建设方案业务多平台怎么样
  • 有哪些好的网站直通车怎么开
  • 唐山做网站价格搜索引擎排行榜前十名
  • 新加坡注册公司吉安seo网站快速排名
  • 网站设计用的技术自创网站
  • 天津建设工程seo平台优化服务
  • 建设银行网站的特点优势近期国内新闻摘抄
  • 制作网站的专业公司哪家好bt磁力王
  • 桂林骏程网站建设搜索引擎广告优化
  • 购物网站开发背景及意义网站怎么制作
  • 宁波建网站哪家好营销策划公司名字
  • 网站群信息管理系统郑州中原区最新消息
  • 社保网站是每月1-6号都是在建设中的吗企业官网
  • 杭州置地电商基地网站建设百度一下照片识别
  • 技术支持 东莞网站建设母婴护理网络营销的概念及内容
  • 建设银行的社会招聘网站seo网站外包公司
  • 解释seo网站推广seo推广绩效考核指标是什么
  • 做网站后期费用软文写作技巧有哪些
  • 南通装修网站大全网络营销方式对比分析