Я использую RecyclerView, который содержит CardViews с TextView и ImageView (каждая карта представляет собой город). У меня также есть onClickListener на каждой карте, которая ведет меня к списку музея в городе. (RecyclerView заполняется ArrayList). Список представляет собой RecyclerView, состоящий из одного и того же Cardview, который прокручивается по вертикали.
Когда в городе есть только один музей, как я могу отобразить уникальный CardView в центре экрана?
Это действие xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.bebbo203.mymuseum.MuseumActivity">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/recyclerViewMuseum"
android:scrollbars="vertical"
android:scrollIndicators="none"
android:gravity="center_horizontal"
/>
</RelativeLayout>
И это RecyclerView xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
xmlns:card_view="http://schemas.android.com/apk/res-auto">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/cardView"
card_view:cardCornerRadius="2dp"
card_view:cardUseCompatPadding="true"
android:gravity="center_horizontal"
android:animateLayoutChanges="true"
>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:id="@+id/imageViewList"
android:layout_gravity="center_horizontal|top"
android:adjustViewBounds="true"
android:scaleType="centerCrop"/>
<TextView
android:id="@+id/textViewList"
android:layout_width="match_parent"
android:layout_height="150dp"
android:textSize="40sp"
android:textIsSelectable="false"
android:textAlignment="center"
android:gravity="fill"
android:textStyle="bold"
android:layout_weight="1"
android:layout_gravity="center_horizontal|top"/>
</FrameLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>`
Спасибо за помощь.
Итак, это MainActivity. Список городов. Здесь все хорошо.
Когда я нажимаю на Parigi, у которого есть только один музей, я хотел показать одиночную карту в центре экрана.
(И если это возможно, я хотел бы сделать картографию, начиная с центра экрана, а не сверху. Например, если центральное картографирование всегда находится в центре, когда я открываю действие. Например, перевод NationalGallery на центр, поддерживающий порядок другого)