Android 在哪里可以获得此可滚动/可扩展的条形图视图/重选?
在哪里可以找到此视图/资源?我已经在几个应用程序上看到了它。它应该会暴露一些隐藏的布局 以下是我提到的视图/资源: 在这里,在灰色背景上,您还可以看到隐藏的布局:Android 在哪里可以获得此可滚动/可扩展的条形图视图/重选?,android,user-interface,material-design,android-resources,Android,User Interface,Material Design,Android Resources,在哪里可以找到此视图/资源?我已经在几个应用程序上看到了它。它应该会暴露一些隐藏的布局 以下是我提到的视图/资源: 在这里,在灰色背景上,您还可以看到隐藏的布局: 协调布局的子视图可以通过使用底部板材行为启用标准底部板材特征。在这样做的过程中,我们可以处理底部锚定、上下拖动手势支持和动画状态转换等 属性: behavior\u hiddeble:确定在使用下拉手势时是否可以隐藏工作表(请记住,它始终可以通过编程方式隐藏)。对于标准底部图纸,默认值为false,对于模式底部图纸,默认值为true
协调布局的子视图可以通过使用
底部板材行为启用标准底部板材特征。在这样做的过程中,我们可以处理底部锚定、上下拖动手势支持和动画状态转换等
属性:
behavior\u hiddeble
:确定在使用下拉手势时是否可以隐藏工作表(请记住,它始终可以通过编程方式隐藏)。对于标准底部图纸,默认值为false,对于模式底部图纸,默认值为true
behavior\u draggable
:确定在使用拖动手势时是否可以折叠/展开图纸(请记住,需要实现自定义方式来展开/折叠图纸)。默认值为true
行为\u skipCollapsed
:确定隐藏图纸时是否应忽略折叠状态。如果行为_hideable未设置为true,则这不会影响。默认值为false
行为\u fitToContents
:确定展开工作表的高度是否包裹其内容。或者,它分两个阶段展开:父容器高度的一半,父容器的全高。默认值为true
行为\u half ExpandedRatio
:确定处于半展开状态时板材的高度(作为父容器高度的比率)。这不影响behavior_fitToContents是否未设置为false且应大于peek height。默认值为0.5(材质指南中的建议比率)
行为\u expandedOffset
:确定处于展开状态时图纸与父容器顶部的偏移量。这不影响behavior_fitToContents是否未设置为false,并且在半展开状态下应大于偏移量。默认值为0dp(图纸顶部与父容器顶部匹配)
behavior\u peek height
:板材的初始“peek”(折叠状态)高度。默认值为auto,它在父容器的16:9比率关键线处设置窥视高度。否则,可以使用尺寸(或像素值,以编程方式)。
现在实施:
layout\u main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto">
<com.google.android.material.appbar.AppBarLayout
app:elevation="0dp"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:background="@android:color/transparent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
/>
</com.google.android.material.appbar.AppBarLayout>
<!-- Adding bottom sheet after main content -->
<include
layout="@layout/bottomsheet_layout" />
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView 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:orientation="vertical"
app:behavior_hideable="false"
app:behavior_peekHeight="115dp"
app:layout_behavior="@string/bottom_sheet_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="110dp"
android:background="@android:color/transparent"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="30dp"
android:scaleType="fitXY"
android:src="@drawable/frame_curved_border_top" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:background="@color/white">
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:layout_marginTop="3dp"
android:fontFamily="@font/opensans_semibold"
android:text=" Siliguri - Gangtok (6123)"
android:textSize="16sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:layout_marginBottom="4dp"
android:fontFamily="@font/opensans_bold"
android:text="8:00 AM - 6:00 AM"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<TextView
android:id="@+id/textView15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="23dp"
android:fontFamily="@font/opensans_semibold"
android:text="STNM Government"
android:textSize="13sp"
app:layout_constraintBottom_toTopOf="@+id/textView14"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:fontFamily="@font/opensans_bold"
android:text="Journey Updates"
android:textSize="16sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:drawablePadding="8dp"
android:drawableTint="@color/light_grey"
android:fontFamily="@font/opensans_regular"
android:text="Driver started the journey"
android:textAlignment="center"
android:textSize="16sp" />
<View
android:layout_width="2dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:background="#ddd" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:drawablePadding="8dp"
android:drawableTint="@color/light_grey"
android:fontFamily="@font/opensans_regular"
android:text="Driver has left the bus stop (SNT)"
android:textAlignment="center"
android:textSize="16sp" />
<View
android:layout_width="2dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:background="#ddd" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="24dp"
android:layout_marginTop="16dp"
android:drawablePadding="8dp"
android:drawableTint="@color/light_grey"
android:fontFamily="@font/opensans_regular"
android:text="Driver is on the way"
android:textAlignment="center"
android:textSize="16sp" />
<View
android:layout_width="2dp"
android:layout_height="30dp"
android:layout_gravity="center"
android:layout_marginTop="8dp"
android:background="#ddd" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
现在,您有了其他选项,如MotionLayout
,以在Android中实现相同的结果,这取决于您的决定。如果您只需要一个简单的片段对话框
实现,而不需要拖拽效果,我也会用它更新答案。如果有帮助,请选择它作为答案