我有一个简单的布局和回收站。我用适配器喂它,并为回收商设置GridLayoutManager
。带GridLayoutManager的RecyclerView - 布局项目
<android.support.v7.widget.RecyclerView
android:id="@+id/scripts_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="50dp"
android:verticalSpacing="20dp"
android:clipToPadding="false"
android:orientation="vertical"
app:layoutManager="android.support.v7.widget.GridLayoutManager"
tools:listitem="@layout/tmpl_script"
android:paddingBottom="20dp"
android:layout_marginEnd="20dp"
android:layout_marginRight="20dp"
android:paddingTop="30dp"
app:layout_gravity="center" />
活动
RecyclerView recyclerView = (RecyclerView)findViewById(R.id.scripts_recycler_view);
recyclerView.setAdapter(adapter);
int columns = getResources().getInteger(R.integer.scripts_columns);
recyclerView.setLayoutManager(new GridLayoutManager(this, columns));
recyclerView.setHasFixedSize(true);
项目
<LinearLayout
android:layout_width="300dp"
android:layout_height="300dp"
android:background="@drawable/game_border"
android:gravity="center"
android:orientation="vertical">
我有两个问题:
- 有行
- 项目不CENTE之间没有空格红色内
我试过Android Studio的所有属性,但它们没有任何效果。我GOOGLE了一下,打开了很多问题,但我仍然没有运气。我应该使用什么魔法财产?
正如您所看到的项目位于屏幕左侧。我想把它移到中心位置。第一排和第二排之间没有空间。
任何人有想法,如何居中物品?我会添加单列的另一张照片。 –
也许传递一个自定义布局参数重心=中心?但我没有找到一个二传手。 –
我交换了一个GridView,最后瓷砖居中。 –