Android 断片
我正在片段中使用RecyclerView。我希望片段在宽度和高度上与父片段匹配。但这是我的输出 碎片周围还有空间。我想消除这一点。我已经尝试了所有方法,例如,将第三个参数设为false,使用父容器,更改LayoutParams以匹配父对象,但没有任何效果 我的代码:- Fragment.xmlAndroid 断片,android,android-fragments,android-relativelayout,Android,Android Fragments,Android Relativelayout,我正在片段中使用RecyclerView。我希望片段在宽度和高度上与父片段匹配。但这是我的输出 碎片周围还有空间。我想消除这一点。我已经尝试了所有方法,例如,将第三个参数设为false,使用父容器,更改LayoutParams以匹配父对象,但没有任何效果 我的代码:- Fragment.xml <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android
<?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"
/>
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>
填充内容应位于“内容”\u start根布局后,该片段正在添加到中。同时发布回收器视图的行post也
app\u bar\u start.xml
。这会有什么帮助?很可能您正在从app\u bar\u start
布局的一些视图上添加片段
。在任何资源文件中都没有应用填充。您在谈论哪些填充先生?在app_bart_start里面你有内容_start是一个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>
<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>
<?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>
@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();
}