我在我的应用中使用了RecyclerView,代码如下:
mLayoutManagerMonth = new StaggeredGridLayoutManager(7, StaggeredGridLayoutManager.VERTICAL);
monthRecycle.setLayoutManager(mLayoutManagerMonth);
RecyclerView.Adapter mMonthAdapter = new MonthAdapter(populateMonthData(persianYear , persianMonth , persianDay) , MonthActivity.this);
monthRecycle.setAdapter(mMonthAdapter);
这是我的xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layoutDirection="rtl">
<include layout="@layout/month_layout"/>
<android.support.design.widget.NavigationView
android:id="@+id/navigationView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textAlignment="gravity"
android:layout_gravity="right"
android:background="#E0E0E0">
<android.support.v7.widget.RecyclerView
android:id="@+id/menuList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="100dp"
android:layout_marginTop="25dp"
android:layout_marginRight="25dp"
android:layout_marginLeft="25dp"
android:textDirection="rtl"/>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
这是我的month_layout xml文件:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
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"
xmlns:fab="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/month"
android:orientation="vertical"
android:layoutDirection="rtl"
tools:layout_editor_absoluteY="25dp"
tools:layout_editor_absoluteX="0dp">
<android.support.v7.widget.Toolbar
android:id="@+id/toolBar"
android:layout_width="0dp"
android:layout_height="56dp"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="0dp"
app:layout_constraintHorizontal_bias="0.0">
</android.support.v7.widget.Toolbar>
<android.support.v7.widget.RecyclerView
android:id="@+id/monthLayout_recycle_month"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="@+id/toolBar"
app:layout_constraintVertical_bias="1.0"
android:layoutDirection="rtl"
app:layout_constraintBottom_toTopOf="@+id/btnAdd"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginRight="8dp"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="0dp"
app:fab_colorNormal="#e53935"
app:fab_icon="@drawable/ic_add"/>
</android.support.constraint.ConstraintLayout>
我的问题是我希望我的循环查看项目从屏幕右侧开始,我在代码下面设置但是ID不起作用!
android:layoutDirection="rtl"
感谢您的帮助
答案 0 :(得分:0)
var param = parameter as string;
这应该可以解决问题。把它放在这一行之后。
mLayoutManagerMonth.setReverseLayout(true);