我正在嘗試實現具有反向recyclerview的屏幕。新項目正在從底部添加,但我有一個imageview在recyclerview之上。這是我想要達到的。 如何使用Recyclerview來查看?
在添加新項目,ImageView的應得動。我怎樣才能做到這一點?我應該使用協調員佈局嗎?在此先感謝您的答覆
我正在嘗試實現具有反向recyclerview的屏幕。新項目正在從底部添加,但我有一個imageview在recyclerview之上。這是我想要達到的。 如何使用Recyclerview來查看?
在添加新項目,ImageView的應得動。我怎樣才能做到這一點?我應該使用協調員佈局嗎?在此先感謝您的答覆
我建議使用新的Android的ViewGroup ConstraintLayout
。
來自官方的文檔:
它類似於所有的意見都按照兄弟的意見和父佈局之間的關係奠定了
RelativeLayout
,但它比RelativeLayout
更靈活,更容易與Android Studio的佈局編輯器來使用。
https://developer.android.com/training/constraint-layout/index.html
compile 'com.android.support.constraint:constraint-layout:1.0.2'
佈局例如:
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="@+id/recycler_view"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"/>
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent">
</android.support.v7.widget.RecyclerView>
</android.support.constraint.ConstraintLayout>
感謝您的回答,我從來沒有使用ConstraintLayout,但我會嘗試 – Hmm
使用retaive佈局父。現在設置recyclerview高度WRAP_CONTENT並將其設置爲alignparent_bottom = TRUE,並設置上述= recyclerviewID –
-Thanks很多圖像視圖,我想更復雜:再次 – Hmm
d它的工作原理,感謝有關放置'ImageView'作爲第一個項目是什麼你'RecyclerView'? – azizbekian