2017-04-25 1 views
-2

J'utilise un RecyclerView dans un fragment. Je veux que le fragment corresponde au parent en largeur et en hauteur. Mais ceci est ma sortie.Supprimer la marge en fragment

My output

Il y a que l'espace étant laissé autour du fragment. Je veux éliminer cela. J'ai tout essayé, c'est-à-dire, fausse le troisième paramètre, en utilisant le conteneur parent, en changeant LayoutParams en match_parent mais rien n'a fonctionné.

Mon code: -

fragment.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" 
android:id="@+id/RLGEVENT" 
android:background="@color/white"> 

<android.support.design.widget.FloatingActionButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="bottom" 
    android:clickable="true" 
    android:layout_marginLeft="16dp" 
    android:layout_marginBottom="16dp" 
    android:layout_marginRight="16dp" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentEnd="true" 
    android:src="@drawable/postbutton" 
    android:id="@+id/floatingButton" /> 

<android.support.v7.widget.RecyclerView 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:id="@+id/listView" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentRight="true" 

    /> 

Fragment

@Override 
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { 


    view = inflater.inflate(R.layout.activity_gevent_main, container, false); 

    RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.RLGEVENT); 
    rl.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); 
    rl.invalidate(); 

    //code   

    return view; 
} 

Root.xml

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.v4.widget.DrawerLayout       
    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/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

<include 
    layout="@layout/app_bar_start" 
    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:background="@color/white" 
    android:layout_gravity="start" 
    android:fitsSystemWindows="true" 
    app:insetForeground="@color/white" 
    android:theme="@style/AppTheme.Lolwa" 
    app:headerLayout="@layout/nav_header_start" 
    app:itemTextColor="@color/black" 
    app:menu="@menu/activity_start_drawer" /> 

    </android.support.v4.widget.DrawerLayout> 

Row.xml

<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:id="@+id/card_view" 
    android:layout_height="wrap_content"> 

    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/gEventRowRL" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="5dp" 
     android:background="#fff"> 


     <ImageView 
      android:id="@+id/exampleProfilePic" 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_marginLeft="10dp" 
      android:scaleType="fitXY" 
      android:src="@drawable/background_profile_pic" /> 

     <ImageView 
      android:id="@+id/photoOf" 
      android:layout_width="match_parent" 
      android:layout_height="400dp" 
      android:layout_below="@+id/gEventsDetails" 
      android:scaleType="fitXY" 
      android:src="@drawable/black_total" /> 


     <TextView 
      android:id="@+id/geventTitle" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="10dp" 
      android:layout_toRightOf="@+id/exampleProfilePic" 
      android:text="Title" 
      android:textSize="18sp" 

      /> 

     <TextView 
      android:id="@+id/gEventsDetails" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_alignParentLeft="true" 
      android:layout_below="@+id/exampleProfilePic" 
      android:layout_margin="10dp" 
      android:text="" 
      android:textSize="16sp" /> 


     <TextView 
      android:id="@+id/gEventsDescription" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/geventTitle" 
      android:layout_margin="10dp" 
      android:layout_toRightOf="@+id/photoOf" 
      android:text="" /> 


    </RelativeLayout> 

    </RelativeLayout> 

app_bar_start.xml

<?xml version="1.0" encoding="utf-8"?> 
    <android.support.design.widget.CoordinatorLayout 
    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.example.anubhavr.firebase.StartActivity"> 

    <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 layout="@layout/content_start" /> 


</android.support.design.widget.CoordinatorLayout> 

Activité

@Override 
    protected void onCreate(Bundle savedInstanceState) { 

    setTheme(R.style.AppTheme); 

    super.onCreate(savedInstanceState); 
    overridePendingTransition(R.anim.slide_in, R.anim.slide_out); 

    setContentView(R.layout.activity_start); 

    fragmentManager = getSupportFragmentManager(); 
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
    setSupportActionBar(toolbar); 

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); 
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
      this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); 
    drawer.setDrawerListener(toggle); 
    toggle.syncState(); 

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); 
    navigationView.setNavigationItemSelectedListener(this); 


    com.example.anubhavr.firebase.Global_Events.MainActivity mainActivity = new com.example.anubhavr.firebase.Global_Events.MainActivity(); 
    setListener(mainActivity); 

    fragmentManager.beginTransaction().replace(R.id.nav_home, mainActivity, mainActivity.getTag()).commit(); 


} 
+0

Poster la mise en page de racine, que ce fragment est ajouté à. – azizbekian

+0

Affichez également la ligne de la vue recycleur –

+0

Publiez également 'app_bar_start.xml'. – azizbekian

Répondre

1

Le rembourrage doit être content_start

+0

Aucun remplissage n'est appliqué dans un fichier de ressources. De quel rembourrage parlez-vous monsieur? – THGRoy

+0

A l'intérieur de app_bart_start, vous avez content_start est une mise en page xml, je ne peux pas le voir dans votre question, peut-être me manque. Mais pour ce que je vois votre fragment devrait être à l'intérieur de cela. – cutiko