[英]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.