0
這從來沒有發生在我身上。基本上我有一個導航抽屜佈局,當我顯示一個片段時,它會在所有邊上留下大約10dp的空間,所以它基本上會縮小一點。嚮導航添加邊距Drawr
app_bar_main.xml:
<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:fitsSystemWindows="true"
tools:context="com.app.r6s.MainActivity"
android:background="#464646">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<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/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="@layout/content_main"
android:layout_alignParentStart="true"
android:layout_marginTop="55dp" />
content_main.xml:
<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:id="@+id/show_fragments"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.app.r6s.MainActivity"
tools:showIn="@layout/app_bar_main">
片段我正在努力顯示:
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tab_layout">
</android.support.design.widget.TabLayout>
<view
android:layout_width="wrap_content"
android:layout_height="wrap_content"
class="android.support.v4.view.ViewPager"
android:id="@+id/viewpager"
android:layout_marginTop="48dp"/>
而替換片段代碼:
MyFragment fragment = new MyFragment();
FragmentManager fm = getSupportFragmentManager();
fm.beginTransaction().replace(R.id.show_fragments, fragment).commit();
感謝這實際上解決了這個問題。 – squash
如果你的答案很小,請考慮使用評論。 – AnixPasBesoin
@AnixPasBesoin感謝提醒 – FarshidABZ