gpt4 book ai didi

java - FAB 按钮未显示在嵌套 ScrollView 上

转载 作者:行者123 更新时间:2023-12-02 10:56:37 25 4
gpt4 key购买 nike

我正在尝试在嵌套 ScrollView 中显示 fab more 按钮。我搜索了许多解决方案,但没有找到任何可以在右下角显示 fab more 按钮的解决方案

<?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="match_parent"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">

<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

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

<ImageButton
android:id="@+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="@android:color/white"
app:srcCompat="@drawable/ic_close" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="@android:color/white" />



</LinearLayout>

</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"


android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="@+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">

//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">



<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/grey_10" />



<android.support.v7.widget.RecyclerView
android:id="@+id/print_payment_list"
android:layout_margin="10dp"
android:background="@color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</android.support.v7.widget.RecyclerView>
</LinearLayout>

</LinearLayout>



</android.support.v4.widget.NestedScrollView>
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout

android:id="@+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="?attr/actionBarSize"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_middle"
android:clickable="true"
android:tint="@color/grey_80"
app:backgroundTint="@color/grey_20"
app:fabSize="mini"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_mic" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_middle"
android:clickable="true"
android:tint="@color/grey_80"
app:backgroundTint="@color/grey_20"
app:fabSize="mini"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_photo_camera" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_smlarge"
android:layout_marginLeft="@dimen/spacing_smlarge"
android:layout_marginRight="@dimen/spacing_smlarge"
android:layout_marginTop="@dimen/spacing_middle"
android:clickable="true"
android:tint="@android:color/white"
app:fabSize="normal"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_add" />

<!--android:src="@drawable/ic_close_black_24dp"-->
</FrameLayout>
</LinearLayout>

我在嵌套 ScrollView .scroll 的一个父级中有多个 View ,并且一切正常。唯一的问题是 fab 没有位于右下角位置

任何人都可以帮助我如何实现这一目标吗?因为我是 android 新手。谢谢

enter image description here

我需要像这样放置 fab bar。这是来自 google 的示例图像

最佳答案

试试这个

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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"
android:background="@android:color/white"
android:fitsSystemWindows="true"
android:orientation="vertical">

<android.support.design.widget.AppBarLayout
android:id="@+id/app"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize">

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

<ImageButton
android:id="@+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:background="?attr/selectableItemBackgroundBorderless"
android:tint="@android:color/white"
app:srcCompat="@drawable/ic_close" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:text="Filter All Order"
android:textAppearance="@style/Base.TextAppearance.AppCompat.Title"
android:textColor="@android:color/white" />



</LinearLayout>

</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="@+id/nested_scroll_view"
android:layout_width="match_parent"
android:layout_below="@id/app"
android:layout_above="@+id/fabFrame"
android:layout_height="match_parent"
android:scrollbars="none"
android:scrollingCache="true">
<LinearLayout
android:id="@+id/billBlock"
android:layout_width="match_parent"
android:layout_height="match_parent">

//many inner layout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">



<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="@color/grey_10" />



<android.support.v7.widget.RecyclerView
android:id="@+id/print_payment_list"
android:layout_margin="10dp"
android:background="@color/grey_20"
android:layout_width="match_parent"
android:layout_height="wrap_content">

</android.support.v7.widget.RecyclerView>
</LinearLayout>

</LinearLayout>



</android.support.v4.widget.NestedScrollView>
<FrameLayout
android:id="@+id/fabFrame"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="?attr/actionBarSize"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:orientation="vertical">
<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_mic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_middle"
android:clickable="true"
android:tint="@color/grey_80"
app:backgroundTint="@color/grey_20"
app:fabSize="mini"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_mic" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_call"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="@dimen/spacing_middle"
android:clickable="true"
android:tint="@color/grey_80"
app:backgroundTint="@color/grey_20"
app:fabSize="mini"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_photo_camera" />

<android.support.design.widget.FloatingActionButton
android:id="@+id/fab_add"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/spacing_smlarge"
android:layout_marginLeft="@dimen/spacing_smlarge"
android:layout_marginRight="@dimen/spacing_smlarge"
android:layout_marginTop="@dimen/spacing_middle"
android:clickable="true"
android:tint="@android:color/white"
app:fabSize="normal"
app:rippleColor="@android:color/white"
app:srcCompat="@drawable/ic_add" />

<!--android:src="@drawable/ic_close_black_24dp"-->
</FrameLayout>
</RelativeLayout>

始终对连续 View 使用线性布局,并在要显示右侧或底部等位置时使用框架布局或相对布局。

关于java - FAB 按钮未显示在嵌套 ScrollView 上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51682598/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com