android 获取屏幕的kuand,android - How to move from (and replace) TabLayout and ViewPager to a new fragmen...

I want to navigate from my main screen (which uses a TabLayout and a ViewPager) to a new fragment (which is not a tab).

I want my new fragment to completely cover the screen (and not be a part of the ViewPager).

You can see below how the (upper half of the) main screen looks like, it has 4 tabs.

pdunX.png

This is how the new fragment on top of the main fragment looks like. It was shown after clicking on "Study" from the main screen. As you can see, the TabLayout and ViewPager are not displayed anymore.

vSzWJ.png

In other words, when I am in the main screen (which has a TabLayout and ViewPager) and I perform an action (clicking on Study for example) I want to show a new fragment that covers the entire screen (including the TabLayout and ViewPager). I don't want this new fragment to be a new tab in the TabLayout and ViewPager and I don't want the new fragment to replace another tab. I want the new fragment to completely replace what was previously shown on the screen.

If it helps understanding the question, this how my activity_main.xml (main screen) looks like (it's not the one from the photos). I want to move from here to a new fragment and completely replace this activity_main.xml layout with the new fragment.

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=".MainActivity">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/Theme.MyApp.AppBarOverlay">

android:id="@+id/my_toolbar"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

android:background="?attr/colorPrimary" />

android:id="@+id/tabs"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:background="?attr/colorPrimary"

app:tabSelectedTextColor="@android:color/white"

app:tabTextColor="@android:color/darker_gray" />

android:id="@+id/view_pager"

android:layout_width="match_parent"

android:layout_height="match_parent"

app:layout_behavior="@string/appbar_scrolling_view_behavior" />

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值