fitsSystemWindows失效无法自动padding

aled6825 2016-05-19 08:07:35
楼主实现一个类网易新闻的App,使用Tabhost+ViewPager实现。
同样的自定义Title布局,但发现Tab1可以实现正常的沉浸式,Tab3无论如何都不行,字体被状态栏覆盖。

style:
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.NoActionBar">
</style>


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

<FrameLayout
android:id="@+id/contentLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</FrameLayout>

<android.support.v4.app.FragmentTabHost
android:id="@android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#F6F6F6" >

<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp" >
</FrameLayout>
</android.support.v4.app.FragmentTabHost>

</LinearLayout>


Tab1布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- 标题栏 -->
<RelativeLayout
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/title_color">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="Excerpt"
android:textColor="@color/title_text_color"
android:textSize="20sp" />
</RelativeLayout>

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:textSize="30sp"/>
</LinearLayout>


Tab3布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<!-- 标题栏 -->
<RelativeLayout
android:fitsSystemWindows="true"
android:clipToPadding="true"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/title_color">
<TextView
android:id="@+id/tvTitle"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:text="Tab3"
android:textColor="@color/title_text_color"
android:textSize="20sp" />
</RelativeLayout>

<!-- 滚动标签栏 -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:orientation="horizontal" >
<HorizontalScrollView
android:id="@+id/hvMemoryLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/ivShowMore"
android:scrollbars="none">
<RadioGroup
android:id="@+id/rgLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
</RadioGroup>
</HorizontalScrollView>
<ImageView
android:id="@+id/ivShowMore"
android:layout_width="40dp"
android:layout_height="35dp"
android:layout_alignParentRight="true"
android:background="#FF00FF00"
android:contentDescription="Show more"
android:scaleType="fitXY"
android:src="@drawable/down_narrow" />
</RelativeLayout>

<!-- 内容区域 -->
<android.support.v4.view.ViewPager
android:id="@+id/vpMemoryContent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</android.support.v4.view.ViewPager>

</LinearLayout>


Tab1和Tab3的布局Title部分已使用BC比较过,无任何差异。但Tab1可以正常实现 title_color沉浸到状态栏,fitsSystemWindows也是可以自动padding的,而tab3颜色正常,但fitsSystemWindows却无法自动padding。
请大神帮分析原因,拜谢
...全文
1028 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
To_Drill 2017-11-04
  • 打赏
  • 举报
回复
我也是这个问题啊!楼主解决了没有?
qq_20446983 2017-01-11
  • 打赏
  • 举报
回复
用android.support.design.internal.ScrimInsetsFrameLayout替换代码中@+id/contentLayout的FrameLayout
wx潇潇xw 2016-10-12
  • 打赏
  • 举报
回复
楼主解决了没有, 我也遇到了
athrun00664 2016-09-06
  • 打赏
  • 举报
回复
楼主解决了吗?我也遇到这个问题了!求解.
aled6825 2016-06-03
  • 打赏
  • 举报
回复
无解? 结贴
aled6825 2016-05-23
  • 打赏
  • 举报
回复
引用 7 楼 qq_26763799 的回复:
这个属性不是应该丢在activity的根目录上么?丢tab下不应该吧
这个App是Tabhost+ViewPager布局,内容是根据Tab切换的fragment,所以无法放在根布局上,否则透明设置完全失效,我们的内容页面则下沉到状态栏下
qq_26763799 2016-05-23
  • 打赏
  • 举报
回复
这个属性不是应该丢在activity的根目录上么?丢tab下不应该吧
yiy91 2016-05-23
  • 打赏
  • 举报
回复
贴出来的布局没有问题,可能出现在别的地方
aled6825 2016-05-23
  • 打赏
  • 举报
回复
anyone's online?
aled6825 2016-05-20
  • 打赏
  • 举报
回复
测试过了,只有第一个Tab是正常的,其他tab即使引用tab1的布局也是不行的。所以估计问题不在子代码上,应该是框架代码的问题。
aled6825 2016-05-20
  • 打赏
  • 举报
回复
引用 2 楼 a1047189887 的回复:
android:fitsSystemWindows="true"
没有发现问题呀,拼写出问题eclipse早报错了
God眯眯眼 2016-05-20
  • 打赏
  • 举报
回复
android:fitsSystemWindows="true"
aled6825 2016-05-20
  • 打赏
  • 举报
回复
牛(da)仔(shen)都很忙

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧