简体   繁体   English

Android:仅尝试滚动文本视图时滚动工具栏

[英]Android: Toolbar getting scrolled when only trying to scroll text view

Android: I have created a toolbar using Material science and I am using it in my activity. Android:我已经使用材料科学创建了一个工具栏,并且在我的活动中正在使用它。 My activity contains a text view and 2 Buttons(Prev and Next). 我的活动包含一个文本视图和2个按钮(上一个和下一个)。 The text is multiline so I am using Scrollview,But the issue is when by adding scrollview my toolbar is also getting hidden when I scroll the Text. 文本是多行的,所以我使用的是Scrollview,但是问题是,当添加滚动视图时,滚动文本时我的工具栏也被隐藏了。 I understand this as I am included the toolbar inside the scrollview so it is also getting scrolled. 我了解了这一点,因为我将滚动条包含在滚动视图中,因此滚动条也随之滚动。 But I only want to scroll my text not my toolbar and wants to always show my toolbar at the top. 但是我只想滚动文本而不是工具栏,并且总是要在顶部显示我的工具栏。 Please look at my xml file and let me know the soln. 请查看我的xml文件,并通知我。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <include android:id="@+id/app_bar" layout="@layout/toolbar"/>
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/app_bar"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:text="Singleton"
        android:id="@+id/textView"
        android:layout_marginTop="70dp"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true"
        android:textColor="#212121"/>

    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Next"
        android:id="@+id/button"
        android:layout_alignParentBottom="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true"
        android:layout_marginBottom="10dp"
        android:background="@color/designPrimaryBackgroundColor"
        android:textColor="#FFFFFF"
        android:onClick="onClick"/>

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:id="@+id/single_string"
        android:layout_below="@+id/textView"
        android:layout_centerHorizontal="true" />

</RelativeLayout>

I am using to add the customized toolbar. 我用来添加自定义工具栏。 Please let me know how can I include the toolbar in this file so that it wont get scrolled when I scrolled the text 请让我知道如何在该文件中包含工具栏,以便在滚动文本时不会被滚动

You should have a LinearLayout as the main parent and have the toolbar (include) as the first child and the ScrollView as the second child 您应该将LinearLayout作为主要父对象,并将工具栏(包括)作为第一个孩子,将ScrollView作为第二个孩子

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation:vertical >

    <include android:id="@+id/app_bar" layout="@layout/toolbar" />

    <ScrollView android:layout_width="match_parent"
        android:layout_height="match_parent" >
        ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在视图分页器中滚动时,折叠工具栏不会折叠 - Collapsing Toolbar not collapsing when scrolled in view pager 滚动列表视图时编辑文本值被清除 - Edit text values getting cleared when list view is scrolled 如何在android中滚动子滚动视图时停止滚动父滚动视图? - How to stop the scrolling of parent scroll view when child scroll view is scrolled in android? Android CoordinatorLayout:仅在列表开始滚动时滚动工具栏 - Android CoordinatorLayout : ToolBar scroll only when list starts scrolling Android:当列表滚动到顶部时如何显示工具栏? - Android: How to show toolbar when the list is scrolled to top? Android折叠式工具栏,仅在用户触摸回收器视图时折叠 - Android collapsing toolbar, collapse only when user touches recycler view 滚动时折叠工具栏不会折叠 - Collapsing toolbar not collapsing when scrolled PopupMenu显示时滚动工具栏 - Toolbar scrolled when PopupMenu showes 锚定到应用程序栏布局时,Text View不会在工具栏下滚动 - Text View does'nt scroll under Toolbar when anchored to app bar layout 工具栏隐藏在listView中的向上滚动中,但向下滚动时不会返回 - Toolbar is hiding on Scroll upward in listView but don't come back when scrolled downward
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM