你在哪里可以买到这个 scrollable/expandable 酒吧 View/Resrouce?
Where can you get this scrollable/expandable bar View/Resrouce?
我在哪里可以找到这个 View/Resource?我在几个应用程序上看到过它。它应该会暴露一些隐藏的布局。
这里是View/Resource我说的:
在这里,在灰色的背景上,您还可以看到隐藏的布局:
CoordinatorLayout
的子视图可以使用 BottomSheetBehavior
启用标准底部 Sheet 特性。这样做时,底部锚定、拖动 up/down 手势支持和动画状态转换等都为我们处理。
属性:
behavior_hideable
:确定在使用向下拖动手势时是否可以隐藏 sheet(请记住它始终可以通过编程方式隐藏)。 Standard Bottom Sheets 的默认值为 false,Modal Bottom Sheets.
的默认值为 true
behavior_draggable
:确定 sheet 在使用拖动手势时是否可以 collapsed/expanded(请记住 expand/collapse sheet 将需要实施)。默认值为真。
behavior_skipCollapsed
:确定隐藏 sheet 时是否应忽略折叠状态。如果 behavior_hideable 未设置为 true,这不会影响。默认值为 false。
behavior_fitToContents
:确定展开的sheet的高度是否包裹其内容。或者,它分两个阶段扩展:父容器高度的一半,父容器的全高。默认值为真。
behavior_halfExpandedRatio
:确定 sheet 处于 half-expanded 状态时的高度(作为父容器高度的比率)。如果 behavior_fitToContents 未设置为 false 并且应该大于 peek 高度,这不会影响。默认值为 0.5(Material 指南中推荐的比率)。
behavior_expandedOffset
:确定sheet在展开状态下距父容器顶部的偏移量。如果 behavior_fitToContents 未设置为 false 且应大于处于 half-expanded 状态时的偏移量,这不会影响。默认值为 0dp(sheet 的顶部与父容器的顶部匹配)。
behavior_peekHeight
:sheet的初始“窥视”(折叠状态)高度。默认值为 auto,它在父容器的 16:9 ratio keyline 处设置 peek 高度。否则可以使用维度(或像素值,以编程方式)。
现在执行:
layout_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>
bottomsheet_layout.xml
<?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>
您可以将其用作 frame_curved_border_top.png
现在您可以选择 MotionLayout
等其他选项来实现 Android 中的相同结果,由您决定。如果您只想要一个没有拖动效果的简单 FragmentDialog
实现,我也会用它来更新答案。如果有帮助,请 select 作为答案。
我在哪里可以找到这个 View/Resource?我在几个应用程序上看到过它。它应该会暴露一些隐藏的布局。
这里是View/Resource我说的:
在这里,在灰色的背景上,您还可以看到隐藏的布局:
CoordinatorLayout
的子视图可以使用 BottomSheetBehavior
启用标准底部 Sheet 特性。这样做时,底部锚定、拖动 up/down 手势支持和动画状态转换等都为我们处理。
属性:
behavior_hideable
:确定在使用向下拖动手势时是否可以隐藏 sheet(请记住它始终可以通过编程方式隐藏)。 Standard Bottom Sheets 的默认值为 false,Modal Bottom Sheets.
behavior_draggable
:确定 sheet 在使用拖动手势时是否可以 collapsed/expanded(请记住 expand/collapse sheet 将需要实施)。默认值为真。
behavior_skipCollapsed
:确定隐藏 sheet 时是否应忽略折叠状态。如果 behavior_hideable 未设置为 true,这不会影响。默认值为 false。
behavior_fitToContents
:确定展开的sheet的高度是否包裹其内容。或者,它分两个阶段扩展:父容器高度的一半,父容器的全高。默认值为真。
behavior_halfExpandedRatio
:确定 sheet 处于 half-expanded 状态时的高度(作为父容器高度的比率)。如果 behavior_fitToContents 未设置为 false 并且应该大于 peek 高度,这不会影响。默认值为 0.5(Material 指南中推荐的比率)。
behavior_expandedOffset
:确定sheet在展开状态下距父容器顶部的偏移量。如果 behavior_fitToContents 未设置为 false 且应大于处于 half-expanded 状态时的偏移量,这不会影响。默认值为 0dp(sheet 的顶部与父容器的顶部匹配)。
behavior_peekHeight
:sheet的初始“窥视”(折叠状态)高度。默认值为 auto,它在父容器的 16:9 ratio keyline 处设置 peek 高度。否则可以使用维度(或像素值,以编程方式)。
现在执行:
layout_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>
bottomsheet_layout.xml
<?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>
您可以将其用作 frame_curved_border_top.png
现在您可以选择 MotionLayout
等其他选项来实现 Android 中的相同结果,由您决定。如果您只想要一个没有拖动效果的简单 FragmentDialog
实现,我也会用它来更新答案。如果有帮助,请 select 作为答案。