Je suis nouveau dans Android et j'implémente un tiroir de navigation, Jusqu'ici j'ai réussi à lister mes articles dans le tiroir et ai ajouté un fragment dans mon framelayout. La page d'accueil fonctionne normalement, mais lorsque j'ouvre le tiroir, les boutons de mon encadrement apparaissent sur le dessus du tiroir de navigation.Le contenu de FrameLayout apparaît sur le tiroir de navigation ci-dessus: Android
J'ai besoin de faire apparaître le framelayout sous le tiroir de navigation.
code Mon comme suit
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.shimplyapp.MainActivity" >
<fragment
android:id="@+id/navigation_drawer"
android:name="com.example.shimplyapp.NavigationDrawerFragment"
android:layout_width="@dimen/navigation_drawer_width"
android:layout_height="match_parent"
android:layout_gravity="start"
tools:layout="@layout/fragment_navigation_drawer" />
</android.support.v4.widget.DrawerLayout>
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</FrameLayout>
</RelativeLayout>
fragment_navigation_drawer.xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="@android:color/black"
tools:context="com.example.shimplyapp.NavigationDrawerFragment" />
home_default.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:gravity="center"
android:orientation="vertical" >
<EditText
android:id="@+id/etxt_sn_enter_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="0dp"
android:hint="enter_search_ item here.."
android:inputType="text"
android:maxLength="15"
android:singleLine="true" />
<Button
android:id="@+id/btn_lm_search_number"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="15dp"
android:text="search"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_lm_view_stores"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="15dp"
android:text="store"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
<Button
android:id="@+id/btn_lm_view_deals"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_marginTop="15dp"
android:text="deal"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Voici mon fragment d'appel de MainActivity
@Override
public void onNavigationDrawerItemSelected(int position) {
Fragment fragment = null;
FragmentManager fragmentManager;
//flag a global variable initially flag = 0;
if(flag ==0){
fragment = new HomePage();
fragmentManager.beginTransaction().replace(R.id.container, fragment).commit();
flag = 1;
}
//..... rest is switch cases for calling different fragments
}
lieu la mise en page de cadre au-dessus de la navigation tiroir en xml –