NestedScrollView不会显示包含内容和动态数据的卡片

时间:2017-01-06 13:13:15

标签: android android-layout android-fragments dynamic

我有一个带有查看寻呼机的活动,我正在加载片段,其中NestedScrollView为父母,其中包含卡片。卡中的数据是动态加载的,并且没有固定的高度。该卡的height设置为wrap_content

问题是NestedScrollView在加载数据后没有正确显示卡片。在某些情况下,卡片相互重叠,而在某些情况下,卡片根本不可见(通常是最后一张)。

活动:

<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
    android:id="@+id/activity_generic_candidate_profile"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true"
    tools:context="com.interviewair.interviewairforemployer.ui.genericCandidateProfile.GenericCandidateProfileActivity">

    <android.support.design.widget.AppBarLayout
        android:id="@+id/appbarlayout_all"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fitsSystemWindows="true"
        android:theme="@style/AppTheme.AppBarOverlay">

        <android.support.design.widget.CollapsingToolbarLayout
            android:id="@+id/collapsingtoolbar_genericcandidateprofile"
            android:layout_width="match_parent"
            android:layout_height="300dp"
            android:fitsSystemWindows="true"
            app:contentScrim="?attr/colorPrimary"
            app:expandedTitleTextAppearance="@android:color/transparent"
            app:layout_scrollFlags="scroll|exitUntilCollapsed">

            <FrameLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">

                <FrameLayout
                    android:layout_width="match_parent"
                    android:layout_height="150dp">

                    <View
                        android:layout_width="match_parent"
                        android:layout_height="match_parent"
                        android:alpha="0.5"
                        android:background="@color/black" />
                    <ImageView
                        android:layout_width="100dp"
                        android:layout_height="100dp"
                        android:src="@drawable/ic_play_circle_outline_black_24px"
                        android:tint="@color/white"
                        android:elevation="10dp"
                        android:alpha="0.7"
                        android:layout_gravity="center"/>
                </FrameLayout>

                <de.hdodenhof.circleimageview.CircleImageView
                    android:id="@+id/circleimageview_genericcandidateprofile_photo"
                    android:layout_width="75dp"
                    android:layout_height="75dp"
                    android:layout_gravity="center_vertical"
                    android:layout_marginStart="@dimen/margin_10"
                    android:src="@drawable/ic_person_outline_white_48px"
                    app:civ_border_color="@color/white"
                    app:civ_border_width="1.5dp" />

                <LinearLayout
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:layout_gravity="bottom"
                    android:layout_marginBottom="30dp"
                    android:layout_marginStart="@dimen/margin_10"
                    android:orientation="vertical">

                    <TextView
                        android:id="@+id/textview_genericcandidateprofile_name"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/margin_5"
                        android:drawablePadding="@dimen/padding_5"
                        android:gravity="center_vertical"
                        android:textColor="@color/white"
                        android:textSize="@dimen/di_text_medium"
                        android:textStyle="bold" />

                    <TextView
                        android:id="@+id/textview_genericcandidateprofile_title"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/margin_5"
                        android:alpha="0.8"
                        android:drawableLeft="@drawable/ic_work_black_18dp"
                        android:drawablePadding="@dimen/padding_5"
                        android:gravity="center_vertical"
                        android:textColor="@color/white"
                        android:textSize="@dimen/di_text_regular" />

                    <TextView
                        android:id="@+id/textview_genericcandidateprofile_location"
                        android:layout_width="match_parent"
                        android:layout_height="wrap_content"
                        android:layout_marginBottom="@dimen/margin_5"
                        android:alpha="0.8"
                        android:drawableLeft="@drawable/ic_location_on_black_18px"
                        android:drawablePadding="@dimen/padding_5"
                        android:gravity="center_vertical"
                        android:text="Mumbai, Maharashtra"
                        android:textColor="@color/white"
                        android:textSize="@dimen/di_text_regular" />
                </LinearLayout>
            </FrameLayout>

            <android.support.v7.widget.Toolbar
                android:id="@+id/toolbar_genericcandidateprofile"
                android:layout_width="match_parent"
                android:layout_height="?attr/actionBarSize"
                app:layout_collapseMode="pin"
                app:popupTheme="@style/AppTheme.PopupOverlay" />

        </android.support.design.widget.CollapsingToolbarLayout>

        <android.support.design.widget.TabLayout
            android:id="@+id/tablayout_genericcandidateprofile_tab"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            app:layout_collapseMode="pin"
            app:tabGravity="fill"
            app:tabIndicatorColor="@color/white"
            app:tabIndicatorHeight="5dp"
            app:tabMode="scrollable"
            app:tabSelectedTextColor="@color/white"
            app:tabTextColor="@color/grey500" />
    </android.support.design.widget.AppBarLayout>

    <android.support.v4.view.ViewPager
        android:id="@+id/viewpager_genericcandidateprofile_pager"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        app:layout_behavior="@string/appbar_scrolling_view_behavior" />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="bottom|end"
        android:layout_marginEnd="@dimen/fab_margin"
        android:layout_marginBottom="@dimen/fab_margin"
        app:borderWidth="0dp"
        app:elevation="6dp"
        app:pressedTranslationZ="12dp"
        android:clickable="true"
        app:rippleColor="@color/colorPrimary"
        android:src="@drawable/ic_dashboard_white_24px"/>
</android.support.design.widget.CoordinatorLayout>

正在加载的片段:

    

    <android.support.v7.widget.CardView
        android:id="@+id/cardview_overview_skills"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="@dimen/margin_5">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:padding="@dimen/padding_10">

            <TextView
                android:id="@+id/textview_overview_skilltitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawablePadding="@dimen/padding_5"
                android:gravity="center_vertical"
                android:text="@string/text_skills"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/di_text_regular" />

            <com.dpizarro.autolabel.library.AutoLabelUI
                android:id="@+id/autolabel_overview_skillchips"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textview_overview_skilltitle"
                android:layout_marginTop="@dimen/margin_10"
                autolabel:label_background_res="@drawable/custom_rounded_background"
                autolabel:label_clickable="false"
                autolabel:show_cross="false"
                autolabel:text_color="@android:color/black"
                autolabel:text_size="@dimen/di_text_small" />

            <ImageView
                android:id="@+id/imageview_overview_retry_skills"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_centerInParent="true"
                android:background="@drawable/custom_button_grey_background"
                android:src="@drawable/ic_refresh_black_24px"
                android:tint="@color/colorAccent"
                android:visibility="gone" />

            <ProgressBar
                android:id="@+id/progressbar_overview_skillpb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:indeterminate="true"
                android:visibility="gone" />
        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/cardview_overview_preferredlocation"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardview_overview_skills"
        android:layout_margin="@dimen/margin_5">

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:padding="@dimen/padding_10">

            <TextView
                android:id="@+id/textview_overview_loctitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:text="@string/text_preferred_location"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/di_text_regular" />

            <com.dpizarro.autolabel.library.AutoLabelUI
                android:id="@+id/autolabel_overview_preflocchips"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@+id/textview_overview_loctitle"
                android:layout_marginTop="@dimen/margin_10"
                autolabel:label_background_res="@drawable/custom_rounded_background"
                autolabel:label_clickable="false"
                autolabel:show_cross="false"
                autolabel:text_color="@android:color/black"
                autolabel:text_size="@dimen/di_text_small" />

            <ImageView
                android:id="@+id/imageview_overview_retry_loc"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_centerInParent="true"
                android:background="@drawable/custom_button_grey_background"
                android:src="@drawable/ic_refresh_black_24px"
                android:tint="@color/colorAccent"
                android:visibility="gone" />

            <ProgressBar
                android:id="@+id/progressbar_overview_locpb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_centerInParent="true"
                android:indeterminate="true"
                android:visibility="gone" />
        </RelativeLayout>
    </android.support.v7.widget.CardView>

    <android.support.v7.widget.CardView
        android:id="@+id/cardview_overview_personal"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/cardview_overview_eduexp"
        android:layout_margin="@dimen/margin_5">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:padding="@dimen/padding_5">

            <TextView
                android:id="@+id/textview_overview_personaltitle"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:drawablePadding="@dimen/padding_5"
                android:gravity="center_vertical"
                android:text="@string/text_personal"
                android:textColor="@color/colorPrimary"
                android:textSize="@dimen/di_text_regular" />

            <LinearLayout
                android:id="@+id/linearlayout_overview_personalwrapper"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/margin_5"
                android:layout_marginTop="@dimen/margin_10"
                android:orientation="vertical"
                android:visibility="gone">

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

                    <TextView
                        android:layout_width="75dp"
                        android:layout_height="wrap_content"
                        android:text="@string/text_email"
                        android:textColor="@color/grey700"
                        android:textSize="@dimen/di_text_regular" />

                    <TextView
                        android:id="@+id/textview_overview_email"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textSize="@dimen/di_text_regular" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_5"
                    android:gravity="center_vertical"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="75dp"
                        android:layout_height="wrap_content"
                        android:text="@string/text_mobile"
                        android:textColor="@color/grey700"
                        android:textSize="@dimen/di_text_regular" />

                    <TextView
                        android:id="@+id/textview_overview_mobile"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textSize="@dimen/di_text_regular" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_5"
                    android:gravity="center_vertical"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="75dp"
                        android:layout_height="wrap_content"
                        android:text="@string/text_dob"
                        android:textColor="@color/grey700"
                        android:textSize="@dimen/di_text_regular" />

                    <TextView
                        android:id="@+id/textview_overview_dob"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textSize="@dimen/di_text_regular" />
                </LinearLayout>

                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginTop="@dimen/margin_5"
                    android:gravity="center_vertical"
                    android:orientation="horizontal">

                    <TextView
                        android:layout_width="75dp"
                        android:layout_height="wrap_content"
                        android:text="@string/text_gender"
                        android:textColor="@color/grey700"
                        android:textSize="@dimen/di_text_regular" />

                    <TextView
                        android:id="@+id/textview_overview_gender"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@color/black"
                        android:textSize="@dimen/di_text_regular" />
                </LinearLayout>
            </LinearLayout>

            <ImageView
                android:id="@+id/imageview_overview_retry_personal"
                android:layout_width="30dp"
                android:layout_height="30dp"
                android:layout_gravity="center"
                android:background="@drawable/custom_button_grey_background"
                android:src="@drawable/ic_refresh_black_24px"
                android:tint="@color/colorAccent"
                android:visibility="gone" />

            <ProgressBar
                android:id="@+id/progressbar_overview_personalpb"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:indeterminate="true"
                android:visibility="gone" />
        </LinearLayout>
    </android.support.v7.widget.CardView>
</RelativeLayout>

0 个答案:

没有答案