recyclerview项目之间的空格

时间:2017-04-14 20:56:45

标签: android android-recyclerview

我在recyclerview和imageslider之间获得了空格。

这是我的片段布局:

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<com.daimajia.slider.library.SliderLayout
    android:id="@+id/slider"
    android:layout_width="match_parent"
    custom:pager_animation="Accordion"
    custom:auto_cycle="true"
    custom:indicator_visibility="visible"
    custom:pager_animation_span="1100"
    android:layout_height="200dp"/>

<com.daimajia.slider.library.Indicators.PagerIndicator
    android:id="@+id/custom_indicator"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    custom:selected_color="#0095BF"
    custom:unselected_color="#55333333"
    custom:shape="oval"
    custom:selected_padding_left="5dp"
    custom:selected_padding_right="5dp"
    custom:unselected_padding_left="5dp"
    custom:unselected_padding_right="5dp"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    custom:selected_width="6dp"
    custom:selected_height="6dp"
    custom:unselected_width="6dp"
    custom:unselected_height="6dp"
    android:layout_marginBottom="20dp"
    />
<com.daimajia.slider.library.Indicators.PagerIndicator
    android:id="@+id/custom_indicator2"
    style="@style/AndroidImageSlider_Corner_Oval_Orange"
    android:layout_centerHorizontal="true"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="20dp"/>


<android.support.v4.widget.SwipeRefreshLayout
android:layout_below="@+id/custom_indicator"
android:id="@+id/swipe_refresh"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">

<android.support.v7.widget.RecyclerView
    android:layout_below="@+id/custom_indicator"
    android:id="@+id/recycler_post"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

[![布局] [1] [1]

1 - 我做错了什么,所以我的回收商查看项目分开了很多?

2 - 当我从底部滑动物品时,它们隐藏在imageslider下面......该怎么办?

我需要帮助

更新:  用于在recyclerview中显示项目的Recycler布局

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ScrollView
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <android.support.v7.widget.CardView
        android:id="@+id/card_view"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:cardBackgroundColor="@color/Grey_50"
        app:cardCornerRadius="0dp"
        app:cardUseCompatPadding="true"
        card_view:cardCornerRadius="dp">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <ImageView
                android:id="@+id/image_news"
                android:layout_width="70dp"
                android:layout_height="50dp"
                android:layout_alignParentEnd="true"
                android:layout_alignParentRight="true"
                android:layout_centerHorizontal="true"
                android:layout_centerVertical="true"
                android:scaleType="center" />

            <TextView
                android:id="@+id/txt_news_title"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_centerVertical="true"
                android:layout_toLeftOf="@+id/image_news"
                android:textSize="13sp" />
            <View
                android:id="@+id/view1"
                android:layout_below="@+id/image_news"
                android:layout_width="match_parent"
                android:layout_height="1dp"
                android:layout_marginTop="10dp"
                 />

            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:orientation="horizontal">


                <ImageView
                    android:id="@+id/recent"
                    android:layout_width="15dp"
                    android:layout_height="15dp"
                    android:layout_alignParentLeft="true"
                    android:layout_alignParentStart="true"
                    android:layout_alignParentTop="true"
                    android:layout_gravity="center"
                    android:layout_marginRight="2dp"
                    android:background="@drawable/ic_recent"
                    android:textAlignment="center" />


                <TextView
                    android:id="@+id/txt_timedate"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_alignParentTop="true"
                    android:layout_toEndOf="@+id/recent"
                    android:layout_toRightOf="@+id/recent"
                    android:text="20:49"
                    android:textColor="@color/Grey_600"
                    android:textSize="16sp" />
            </LinearLayout>

        </RelativeLayout>
    </android.support.v7.widget.CardView>
</ScrollView>

1 个答案:

答案 0 :(得分:1)

1 - 我做错了什么,所以我的回收商查看项目分开了很多?

从XML中移除CREATE EXTERNAL TABLE,并从custom_indicator2移除属性android:layout_marginBottom="20dp"

2 - 当我从底部滑动项目时,它们隐藏在imageslider下面......该怎么办?

custom_indicator删除属性app:layout_behavior="@string/appbar_scrolling_view_behavior"

更新您的XML,如下所示:

SwipeRefreshLayout

更新:我认为问题出在您的<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:custom="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <com.daimajia.slider.library.SliderLayout android:id="@+id/slider" android:layout_width="match_parent" custom:pager_animation="Accordion" custom:auto_cycle="true" custom:indicator_visibility="visible" custom:pager_animation_span="1100" android:layout_height="200dp"/> <com.daimajia.slider.library.Indicators.PagerIndicator android:id="@+id/custom_indicator" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" custom:selected_color="#0095BF" custom:unselected_color="#55333333" custom:shape="oval" custom:selected_padding_left="5dp" custom:selected_padding_right="5dp" custom:unselected_padding_left="5dp" custom:unselected_padding_right="5dp" android:layout_centerHorizontal="true" android:layout_alignParentBottom="true" custom:selected_width="6dp" custom:selected_height="6dp" custom:unselected_width="6dp" custom:unselected_height="6dp"/> <android.support.v4.widget.SwipeRefreshLayout android:id="@+id/swipe_refresh" android:layout_width="match_parent" android:layout_height="match_parent" > <android.support.v7.widget.RecyclerView android:id="@+id/recycler_post" android:layout_width="match_parent" android:layout_height="match_parent" /> </android.support.v4.widget.SwipeRefreshLayout> </LinearLayout> 项目视图中。从项目布局中删除recycler

试试这个:

ScrollView

希望这会有所帮助〜