【问题标题】:set background for activity containing AppbBarLayout为包含 AppbBarLayout 的活动设置背景
【发布时间】:2015-10-15 12:49:19
【问题描述】:

我正在尝试使用 androids CoordinatorLayout 和 FrameLayout。我想要的是一个 工具栏 LinearLayout 显示一些信息 表格布局 列表视图

当列表视图滚动时,工具栏和线性布局应该向上滚动和隐藏,标签应该在顶部。

我有一个布局类型:

<android.support.v4.widget.DrawerLayout
        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:fitsSystemWindows="true">

    <android.support.design.widget.CoordinatorLayout
            xmlns:android="http://schemas.android.com/apk/res/android"
            xmlns:tools="http://schemas.android.com/tools"
            xmlns:app="http://schemas.android.com/apk/res-auto"
            android:id="@+id/coordinatorLayout"
            android:layout_height="match_parent"
            android:layout_width="match_parent">

        <android.support.design.widget.AppBarLayout
                android:id="@+id/appbar"
                android:layout_width="match_parent"
                android:layout_height="wrap_content">

        <-- stuff I want to hide on scrolling -->
            <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    app:layout_scrollFlags="scroll|enterAlways"
                    android:orientation="vertical">

                <include
                        layout="@layout/toolbar"
                        app:layout_scrollFlags="scroll|enterAlways"/>

                <LinearLayout
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        app:layout_scrollFlags="scroll|enterAlways"
                        android:orientation="vertical">
                    <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="Gamercard content"
                            />
                    <TextView
                            android:layout_width="match_parent"
                            android:layout_height="wrap_content"
                            android:text="More Gamercard content"
                            />
                </LinearLayout>

            </LinearLayout>

            <-- stuff I dont want to hide on scrolling -->

            <android.support.design.widget.TabLayout
                    android:id="@+id/tabLayout"
                    android:scrollbars="horizontal"
                    android:layout_below="@+id/toolbar"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"/>


        </android.support.design.widget.AppBarLayout>

        <!-- My Scrollable View -->
        <include layout="@layout/nested_scrolling_container_view"/>

    </android.support.design.widget.CoordinatorLayout>

</android.support.v4.widget.DrawerLayout>

我想要做的是有一张图片作为整个活动的背景,但我看到的是 AppBarLayout 部分总是黑暗的。请帮忙。

【问题讨论】:

    标签: android android-layout android-appbarlayout


    【解决方案1】:

    我可以通过将代码中的 backgroundColor 设置为 Color.TRANSPARENT 以编程方式完成。

    appbar.setBackgroundColor(Color.TRANSPARENT);
    

    【讨论】:

      猜你喜欢
      • 2023-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 2016-05-23
      • 1970-01-01
      相关资源
      最近更新 更多