作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 CollapsingToolbar 添加到我现有的 Activity 中,其中包含自定义 FrameLayout 中的 TabLayout。从我下面的尝试来看,当滚动到顶部时,工具栏没有完全展开,而是消失了。 TabLayout 也不会出现在任何地方。
这是我所拥有的:
<org.corey.android.common_ui.CustomFrameLayout 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="wrap_content"
tools:context=".TestActivity"
tools:ignore="MergeRootFrame">
<android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="256dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">
<android.support.design.widget.CollapsingToolbarLayout
android:id="@+id/collapsing_toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<android.support.design.widget.TabLayout
android:id="@+id/test_tab_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@color/white"
android:minHeight="?attr/actionBarSize"
/>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:layout_collapseMode="parallax" />
</android.support.design.widget.CollapsingToolbarLayout>
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:id="@+id/test_content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white">
<android.support.v4.view.ViewPager
android:id="@+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/button_container"
/>
<FrameLayout
android:id="@+id/button_container"
android:layout_width="match_parent"
android:layout_height="@dimen/test_activity_bottom_button_height"
android:layout_alignParentBottom="true"
android:background="@color/green_success"
android:visibility="gone">
<Button
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:textColor="@android:color/white" />
</FrameLayout>
<FrameLayout
android:id="@id/bottom_button_container"
android:layout_width="match_parent"
android:layout_height="@dimen/bottom_button_height"
android:layout_alignParentBottom="true"
android:background="@color/backgroundDark"
android:visibility="gone">
<Button
android:id="@+id/button"
style="@style/Dark.Button.Primary"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:attr/selectableItemBackground"
android:textColor="@android:color/white" />
</FrameLayout>
<ProgressBar
android:id="@+id/loading"
android:layout_centerInParent="true"
android:visibility="gone"
style="@style/progress_bar_standard"/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
</org.corey.android.common_ui.CustomFrameLayout>
我正在尝试实现这样的目标:https://gist.github.com/iPaulPro/1468510f046cb10c51ea
最佳答案
此处使用match_parent
<org.corey.android.common_ui.CustomFrameLayout 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"
tools:context=".TestActivity"
tools:ignore="MergeRootFrame">
然后使用 app:layout_behavior="@string/appbar_scrolling_view_behavior" 作为相对布局
<RelativeLayout
android:id="@+id/test_content_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior
android:background="@color/white">
3:如果您想将选项卡放在工具栏下方,请使用重力
<android.support.design.widget.TabLayout
android:id="@+id/test_tab_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:background="@color/white"
android:layout_gravity="bottom"
android:minHeight="?attr/actionBarSize"
/>
关于java - CollapsingToolbarLayout 与 TablLayout 不展开或显示选项卡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35858767/
我正在尝试将 CollapsingToolbar 添加到我现有的 Activity 中,其中包含自定义 FrameLayout 中的 TabLayout。从我下面的尝试来看,当滚动到顶部时,工具栏没有
我是一名优秀的程序员,十分优秀!