LinearLayout和NestedScrollView问题

安瓦尔·夸万迪科夫(Anvar Quvandikov)

我想如何使用NestedScrollView,工具栏的视图在顶部,底部的视图在底部。顶视图和底视图工具栏和底视图必须始终就位。

如何在任何设备上实现此结果?感谢您的答复,谢谢。

总是这样:

在此处输入图片说明

这是我的代码:

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <!--This is top-->
    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:background="@color/colorPrimary">
        <!--.........................-->
    </androidx.appcompat.widget.LinearLayoutCompat>


    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:background="@color/colorGreyFragment">
            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content">
            </androidx.constraintlayout.widget.ConstraintLayout>
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>

    <!--This is bottom-->
    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/bottom_buttons_group"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:gravity="center"
        android:background="@color/colorWhite">
        <!--..............................-->
    </androidx.appcompat.widget.LinearLayoutCompat>

</LinearLayout>
自在

你可以这样

<?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"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">
    <!--This is top-->
    <androidx.appcompat.widget.LinearLayoutCompat
        android:id="@+id/toolbar"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"
        android:background="@color/colorPrimary">
        <!--.........................-->
    </androidx.appcompat.widget.LinearLayoutCompat>


    <androidx.core.widget.NestedScrollView
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="0dp">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:background="@color/colorGreyFragment"
            android:orientation="vertical">

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"></androidx.constraintlayout.widget.ConstraintLayout>
        </LinearLayout>
    </androidx.core.widget.NestedScrollView>

    <!--This is bottom-->
    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"/>

</LinearLayout>

我已经用替换了底部的线性布局BottomNavigationView,如果您还需要其他东西,可以在此处替换。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

NestedScrollView和WebView高度问题

在AppBarLayout和NestedScrollView之间放置一个LinearLayout

NestedScrollView和CoordinatorLayout。滚动问题

滚动时CollapsingToolbarLayout和NestedScrollView问题

Flutter tabsView和NestedScrollView滚动问题

NestedScrollView和onInterceptTouchEvent

Android:包括LinearLayout问题

LinearLayout权重问题

Android 上的 LinearLayout 问题

在约束布局中使用NestedScrollView的问题

CoordinatorLayout 中的 NestedScrollView 和 AppBarLayout:无法滚动到 NestedScrollView 结束

Android中View的LinearLayout问题

带有CollapsingToolbar和NestedScrollView的Google Map

CollapsingToolbarLayout和NestedScrollView不起作用

NestedScrollView和Horizontal RecyclerView平滑滚动

如何同时使用NestedScrollView,SwipeRefreshLayout和WebView?

检测AppBarLayout和NestedScrollView的滚动效果

Flutter NestedScrollView 标题与 TabBar 和 TabbarView 反弹

滚动父LinearLayout和Listview

未嵌套在NestedScrollView中但位于同一LinearLayout中时,RecyclerView不会滚动

如何解决LinearLayout中的宽度问题?

CardView与LinearLayout-图像缩放问题

在NestedScrollView的TextInputEditText中选择文本时出现问题

如何在Linearlayout中嵌入ViewPager和LinearLayout?

使用NestedScrollView,AppBarLayout和CoordinatorLayout平滑滚动和滚动

pyinstaller的问题和问题

NestedScrollView中的RecyclerView导致加载缓慢和/或崩溃

使用nestedscrollview 和recycleviews 未检测到视图组的OnTouchListener

NestedScrollView(和ScrollView)不适用于ConstraintLayout