微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

底部的 Instagram 选项菜单

如何解决底部的 Instagram 选项菜单

在当前版本的 instagram 应用程序(今天日期 24-06-2021)中,在按下 hamburgur 按钮(或简单的 3 行图标)时,在个人资料活动/片段中,现在会从底部弹出一个菜单,可以滚动向下滑动,以前点击它会打开一个新的片段/活动

我爱上了这个动画或一个视图,我渴望在我的应用程序中实现它 但问题是我不知道它叫什么

我想知道它到底是什么,pintrest 应用程序中也有类似的动画或视图

屏幕截图

enter image description here

更新 1

我如何从底部工作表导航到一个片段,例如,如果在我的引导表中有 3 个文本视图,我希望如果点击任何文本视图,它应该打开受人尊敬的新片段,即如果单击了 editprofle textView,它会打开 editprofile片段这就是我的底片打开方式

Profile_Fragment.java

accountSettings imageView 点击底部表格打开

accountSettings.setonClickListener(
                v -> {
                    BottomSheet bottomSheet = new BottomSheet();
                    bottomSheet.show(requireActivity().getSupportFragmentManager(),bottomSheet.get Tag());
                }
        );

bottom_sheet_profile.xml

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

    <View
        android:id="@+id/slidedownview"
        android:layout_width="40dp"
        android:layout_height="3dp"
        android:layout_alignParentTop="true"
        android:layout_centerInParent="true"
        android:background="@drawable/rounded_corner_bottomsheetline"
        android:layout_marginTop="11dp"/>

    <TextView
        android:id="@+id/settings"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/slidedownview"
        android:layout_alignParentStart="true"
        android:layout_marginStart="30dp"
        android:layout_marginTop="20dp"
        android:elevation="10dp"
        android:text="@string/settings"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="normal" />

    <TextView
        android:id="@+id/edit_profile"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/settings"
        android:layout_alignParentStart="true"
        android:layout_marginStart="30dp"
        android:layout_marginTop="17dp"
        android:elevation="10dp"
        android:text="@string/edit_profile"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="normal" />

    <TextView
        android:id="@+id/favorite"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/edit_profile"
        android:layout_alignParentStart="true"
        android:layout_marginStart="30dp"
        android:layout_marginTop="17dp"
        android:elevation="10dp"
        android:text="@string/favorite"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="normal" />

    <TextView
        android:id="@+id/log_out"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/favorite"
        android:layout_alignParentStart="true"
        android:layout_marginStart="30dp"
        android:layout_marginTop="17dp"
        android:layout_marginBottom="15dp"
        android:elevation="10dp"
        android:text="@string/log_out"
        android:textColor="@color/white"
        android:textSize="20sp"
        android:textStyle="normal" />


</RelativeLayout>

解决方法

在您的 app.gradle 文件中包含以下库。

implementation 'com.google.android.material:material:<version>'

创建自定义布局 bottom_sheet_dialog_layout.xml

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Settings"
    android:drawableStart="@drawable/ic_settings"
    android:layout_gravity="center_vertical"
    android:padding="8dp"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Archive"
    android:drawableStart="@drawable/ic_archive"
    android:layout_gravity="center_vertical"
    android:padding="8dp"/>
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Your Activity"
    android:drawableStart="@drawable/ic_activity"
    android:layout_gravity="center_vertical"
    android:padding="8dp"/>
....    
....
....

在类文件中

final BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(this);
    bottomSheetDialog.setContentView(R.layout.activity_sof);

    TextView settings = bottomSheetDialog.findViewById(R.id.settings);
    TextView archive = bottomSheetDialog.findViewById(R.id.archive);
    TextView your_activity = bottomSheetDialog.findViewById(R.id.activity);
    ...
    ...
    ...
    bottomSheetDialog.show();

如果你想点击事件

settings.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Toast.makeText(getApplicationContext(),"Copy is Clicked ",Toast.LENGTH_LONG).show();
            bottomSheetDialog.dismiss();
        }
    });

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。