是activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/mainnewfeedcontainer"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/newsfeed_footer"
android:id="@+id/container_content"
android:background="?android:windowBackground"
>
<android.support.v4.widget.DrawerLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/drawer_layout"
android:fitsSystemWindows="true"
tools:openDrawer="start"
>
<include
layout="@layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<android.support.design.widget.NavigationView
android:id="@+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="end"
android:fitsSystemWindows="true"
app:headerLayout="@layout/nav_header_main"
app:menu="@menu/activity_main_drawer"
app:itemTextColor="@color/white"
android:background="@color/black"
app:theme="@style/NavigationTheme"
/>
</android.support.v4.widget.DrawerLayout>
</FrameLayout>
<LinearLayout
android:id="@+id/newsfeed_footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/myprofile_rectangleshape"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="5"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/feedfunctionality"
>
<ImageView
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/feed_icons"
android:gravity="center"
android:text="Feed"
android:id="@+id/feedicon"
android:paddingTop="2dp"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Feed"
android:layout_weight="1"
android:textColor="@color/white"
android:gravity="center"
android:id="@+id/feedicon_text"
android:layout_centerHorizontal="true"
android:layout_below="@+id/feedicon"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/discoverfunctionality"
>
<ImageView
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/discover_icon"
android:gravity="center"
android:paddingTop="2dp"
android:textSize="12sp"
android:layout_centerHorizontal="true"
android:id="@+id/discovericon"
android:text="Feed"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Discover"
android:layout_weight="1"
android:textColor="@color/white"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_below="@+id/discovericon"
android:id="@+id/discover_text"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_weight="1"
android:gravity="center"
android:id="@+id/matchfunctionality"
>
<ImageView
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/matchicon"
android:gravity="center"
android:text="Feed"
android:layout_centerHorizontal="true"
android:paddingTop="2dp"
android:textSize="12sp"
android:id="@+id/matchicon"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Match"
android:layout_weight="1"
android:textColor="@color/white"
android:gravity="center"
android:layout_centerHorizontal="true"
android:id="@+id/match_text"
android:layout_below="@+id/matchicon"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="30dp"
android:layout_height="50dp"
android:layout_weight="1"
android:layout_gravity="center"
android:gravity="center"
>
<ImageView
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/chaticon"
android:gravity="center"
android:paddingTop="2dp"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:id="@+id/chaticon"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Chat"
android:layout_weight="1"
android:textColor="@color/white"
android:gravity="center"
android:layout_centerHorizontal="true"
android:layout_below="@+id/chaticon"
/>
</RelativeLayout>
<RelativeLayout
android:layout_width="30dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
>
<ImageView
android:layout_width="20dp"
android:layout_height="30dp"
android:layout_weight="1"
android:src="@drawable/notificationicon"
android:gravity="center"
android:text="Feed"
android:paddingTop="2dp"
android:layout_centerHorizontal="true"
android:textSize="12sp"
android:id="@+id/noticeicon"
android:textColor="#FFFFFF" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Notice"
android:layout_weight="1"
android:textColor="@color/white"
android:layout_centerHorizontal="true"
android:gravity="center"
android:layout_below="@+id/noticeicon"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
有framelayout,我想通过除底部布局之外的片段替换页面与另一页面
这是MainActivity.class
fragmentTransaction=fragmentManager.beginTransaction();
Fragment fragmentdiscover=new Fragmentdiscover();
fragmentTransaction.replace(R.id.container_content,fragmentdiscover);
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
页面正在替换,但未正确显示,some part is cropping of header
提前致谢
答案 0 :(得分:0)
试试这个
public void pushFragments(Fragment fragment){
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction ft = manager.beginTransaction();
ft.add(R.id.container_content, fragment);
ft.addToBackStack(fragment.getClass().getSimpleName());
ft.commit();
}