image.png
image.png
難點(diǎn)1:
讓視頻view延伸到底部tab慢叨,頂部狀態(tài)欄
難點(diǎn)2:
讓其他fragment view頂部狀態(tài)欄自動(dòng)fitWindow
針對(duì)性的讓部分延伸到頂部
解決方法:
我使用相對(duì)布局,然后讓fragment space區(qū)域ABOVE
底部區(qū)域 然后取消activity的view的fitWindow
屬性琐旁。然后每一個(gè)fragment單獨(dú)計(jì)算fitWindow的高度倍靡,也就是測(cè)量狀態(tài)欄高度,給自己的不需要填充狀態(tài)欄的fragment view設(shè)置一個(gè)狀態(tài)欄高度view弄進(jìn)去產(chǎn)生視覺(jué)錯(cuò)感厢汹。
在切換到直播fragment的時(shí)候移除ABOVE
自動(dòng)填充底部,修改底部導(dǎo)航背景為透明,
private void switchPosition(int index) {
if (index == mLastPosition) {
return;
}
//view_bottom_wrap
RelativeLayout.LayoutParams layoutParams = (RelativeLayout.LayoutParams) binding.fragmentSpace.getLayoutParams();
if (index != 3) {
binding.fragmentSpace.setVisibility(View.VISIBLE);
binding.line1.setBackgroundColor(Color.WHITE);
layoutParams.addRule(RelativeLayout.ABOVE, R.id.view_bottom_wrap);
binding.fragmentSpace.setLayoutParams(layoutParams);
} else {
binding.line1.setBackgroundColor(Color.TRANSPARENT);
binding.fragmentSpace.setVisibility(View.GONE);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
layoutParams.removeRule(RelativeLayout.ABOVE);
binding.fragmentSpace.setLayoutParams(layoutParams);
} else {
layoutParams.addRule(RelativeLayout.ABOVE, 0);
binding.fragmentSpace.setLayoutParams(layoutParams);
}
}
FragmentUtil.replaceFragment(this, arrayList.get(index), false);
mLastPosition = index;
}
布局文件
<?xml version="1.0" encoding="utf-8"?>
<layout>
<data>
</data>
<RelativeLayout 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"
android:orientation="vertical"
tools:context="cn.qssq666.MainActivity">
<FrameLayout
android:id="@+id/fragment_space"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/view_bottom_wrap"
/>
<LinearLayout
android:id="@+id/view_bottom_wrap"
android:background="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:orientation="vertical"
>
<View
style="@style/h_line"
android:id="@+id/line1"
android:layout_width="match_parent"
android:layout_height="1dp" />
<cn.qssq666.radiogroupx.RadioGroupX
android:id="@+id/radiogroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:gravity="center"
android:paddingBottom="@dimen/main_pading_size"
android:paddingTop="@dimen/main_pading_size"
app:orientation="horizontal">
<cn.qssq666.radiogroupx.MyDrawableTopRadioButton
android:id="@+id/radio_btn_1"
style="@style/buttom_strip_radiobutton"
android:layout_weight="1"
android:descendantFocusability="blocksDescendants"
android:textColor="@color/colorThemeBlack"
app:buttontextSize="@dimen/text_size_12"
app:drawableTop="@drawable/selector_btn_tab1"
app:text="頭條"
app:textSize="@dimen/text_size_12" />
<RadioButton
android:id="@+id/radio_btn_2"
style="@style/buttom_strip_radiobutton"
android:layout_weight="1"
android:drawableTop="@drawable/selector_btn_tab2"
android:text="營(yíng)銷(xiāo)課" />
<RadioButton
android:id="@+id/radio_btn_3"
style="@style/buttom_strip_radiobutton"
android:layout_weight="1"
android:drawableTop="@drawable/selector_btn_tab2"
android:text="海報(bào)" />
<cn.qssq666.radiogroupx.MyBadgeRadioButton
android:id="@+id/radio_btn_4"
style="@style/buttom_strip_radiobuttonx"
android:descendantFocusability="blocksDescendants"
app:badgeRadius="8dp"
app:badgetext=""
app:badgetextColor="@color/colorWhite"
app:badgetextSize="5dp"
app:buttontextColor="@color/colorThemeBlack"
app:buttontextSize="@dimen/text_size_12"
app:drawableTop="@drawable/selector_btn_tab3"
app:minBadgeSize="2dp"
app:onlypointer="true"
app:text="視頻" />
<RadioButton
android:id="@+id/radio_btn_5"
style="@style/buttom_strip_radiobutton"
android:drawableTop="@drawable/selector_btn_tab4"
android:text="我的" />
</cn.qssq666.radiogroupx.RadioGroupX>
</LinearLayout>
</RelativeLayout>
</layout>