如何将自定义 ActionBar 设置为 ScrollView 布局内的固定顶部位置?

fra*_*isk 3 eclipse android android-layout

即使滚动它在屏幕顶部保持可见的长数据屏幕,我如何以某种方式设置此操作栏?

工具栏.xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
Run Code Online (Sandbox Code Playgroud)

伙计们,请查看我的更新:我尝试了所有方法,但似乎 actionBar 之后的下一个组件不是在 actionBar 之后设置的,而是在它后面设置的:

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

<include layout="@layout/toolbar" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:fillViewport="true" >

        <LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >

            <TextView
                android:id="@+id/textView1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="TextView" />
        </LinearLayout>
    </ScrollView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

<android.support.v7.widget.Toolbar
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/actionBar"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:background="@color/actionBarBackgroundColor"
    app:contentInsetEnd="0dp"
    app:contentInsetStart="0dp" >
</android.support.v7.widget.Toolbar>

<View
    android:layout_width="match_parent"
    android:layout_height="1dp"
    android:background="#A0A09F" />
Run Code Online (Sandbox Code Playgroud)

项目(日食): Eclipse IDE 中的项目

画面停止: 屏幕停止在顶部显示 acationbar

屏幕向上滚动: 屏幕向上滚动显示操作栏与其他数据一起上升

爪哇:

    Toolbar actionBar = (Toolbar) findViewById(R.id.actionBar);
    actionBar.setTitle("ProTaxi Passageiro");
    actionBar.setSubtitle("Cadastro");
    actionBar.setTitleTextColor(Color.parseColor("#846A1A"));
    setSupportActionBar(actionBar);
Run Code Online (Sandbox Code Playgroud)

Flo*_*ern 5

如果您不希望 Toolbar 随内容一起滚动,则必须将其放在 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 layout="@layout/toolbar" />

    <ScollView
        ...>

        you content here..

    </ScollView>

</LinearLayout>
Run Code Online (Sandbox Code Playgroud)