问题遇到的现象
由于使用Fragment的原因,activity_main就用的TabLayout,然后具体内容在碎片中写,但是activity_main中TabLayout会遮挡Fragment的内容
我的解答思路和尝试过的方法
又由于设置了TabLayout的背景色,透明度 如果使用marginBottom 其实会让TabLayout的透明度收到影响 就不使用marginBottom
我想要达到的结果
有什么办法能不遮挡碎片内容嘛
activity_main:TabLayout
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.circularreveal.coordinatorlayout.CircularRevealCoordinatorLayout
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=".MainActivity"
android:background="@color/white"
android:fitsSystemWindows="true">
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/home_viewPager2"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!--选项卡指示器Indicator 选项卡容器相关Ripple-->
<com.google.android.material.tabs.TabLayout
android:id="@+id/home_tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#CCFFFFFF"
android:minHeight="?attr/actionBarSize"
app:tabIndicatorAnimationMode="elastic"
app:tabIndicatorColor="#FFCCCC"
app:tabIndicatorGravity="top"
app:tabRippleColor="#CCFFFFFF"
app:tabSelectedTextColor="#FFCCCC"
app:tabTextColor="#929299"
app:tabUnboundedRipple="true">
<com.google.android.material.tabs.TabItem
android:id="@+id/item_chat"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:id="@+id/item_find"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<com.google.android.material.tabs.TabItem
android:id="@+id/item_person"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</com.google.android.material.tabs.TabLayout>
</com.google.android.material.circularreveal.coordinatorlayout.CircularRevealCoordinatorLayout>
碎片内容Fragment
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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=".Person.PersonFragment">
<com.google.android.material.appbar.MaterialToolbar
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/black"
app:layout_scrollFlags="scroll|enterAlways|snap" />
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.youth.banner.Banner
android:id="@+id/Home_Banner"
android:layout_width="match_parent"
android:layout_height="250dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginBottom="10dp"
app:banner_radius="12dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/Home_Goods"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>