gabrielemariotti / cardslib

Android Library to build a UI Card
4.66k stars 1.19k forks source link

setupInnerViewElements is never called for CarView #277

Closed mohataher closed 10 years ago

mohataher commented 10 years ago

Hi,

I have a custom card that works OK with cars lists. However, when using it with this layout inside a CardView, I noticed that setupInnerViewElements is never called.

I would like to share the layout to see if there is a solution for this, thanks for this amazing library and thanks for your help.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:card="http://schemas.android.com/apk/res-auto"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    >

    <my.custom.stuff.custom.SlidingUpPanelLayout
        android:id="@+id/slidingLayout"
        android:gravity="bottom"
        app:shadowHeight="0dp"
        app:paralaxOffset="@dimen/paralax_offset"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <FrameLayout
            android:gravity="top"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

            <com.skobbler.ngx.map.SKMapViewHolder
                android:id="@+id/view_group_map"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" />

            <RelativeLayout
                android:id="@+id/chess_board_background"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:background="@drawable/map_background" />

        </FrameLayout>

        <RelativeLayout
            android:id="@+id/slidingContainer"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent">

           <!--<View
                android:id="@+id/transparentView"
                android:visibility="gone"
                android:layout_width="fill_parent"
                android:layout_height="@dimen/map_height"
                android:layout_alignParentTop="true"
               />-->
            <LinearLayout
                android:layout_width="match_parent"
                android:layout_height="60dp"
                android:orientation="horizontal"
                android:layout_alignParentTop="true"
                android:background="@color/white"
                android:id="@+id/layout_text_time_to_destination">

                <it.gmariotti.cardslib.library.view.CardView
                    android:id="@+id/card_view_for_journey_plan"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp"
                    card:card_layout_resourceID="@layout/journey_custom_layout_card_view_generic"/>

                <!--
                <TextView
                android:id="@+id/route_details_time_to_destination"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="x min to"
                android:layout_marginTop="10dp"
                android:textColor="@color/dark_silver"
                android:background="@color/white"
                android:paddingLeft="10dp"
                android:textAppearance="?android:attr/textAppearanceMedium"
                />

                <TextView
                    android:id="@+id/route_details_destination"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="destination"
                    android:layout_marginTop="10dp"
                    android:textColor="@color/dark_silver"
                    android:background="@color/white"
                    android:paddingLeft="5dp"
                    android:textAppearance="?android:attr/textAppearanceMedium"
                    />
                -->
            </LinearLayout>
            <ListView
                android:id="@+id/list"
                android:cacheColorHint="@android:color/white"
                android:drawSelectorOnTop="true"
                android:divider="@null"
                android:background="@color/white"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"
                android:layout_below="@+id/layout_text_time_to_destination"
                android:smoothScrollbar="false"/>
        </RelativeLayout>
    </my.custom.stuff.custom.SlidingUpPanelLayout>

    <!-- more code here -->
</RelativeLayout>
gabrielemariotti commented 10 years ago

Can you provide the layout journey_custom_layout_card_view_generic ?

mohataher commented 10 years ago

This is the xml for journey_custom_layout_card_view_generic

<?xml version="1.0" encoding="utf-8"?>

<RelativeLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:animateLayoutChanges="true"
    android:layout_marginBottom="10dp"
    android:layout_marginRight="10dp"
    android:layout_marginLeft="10dp"
    android:layout_marginTop="10dp">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Medium Text"
        android:id="@+id/text_view_time_from_time_to_generic_card_journey"
        android:layout_alignParentTop="true"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:text="Medium Text"
        android:id="@+id/text_view_duration_generic_card_journey"
        android:layout_alignParentTop="true"
        android:layout_alignParentRight="true"
        android:layout_alignParentEnd="true" />

    <LinearLayout
        android:id="@+id/journey_custome_layout_card_view_generic_transportation_mode_container"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:layout_below="@+id/text_view_time_from_time_to_generic_card_journey"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true">

    </LinearLayout>

    <View
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:background="#D1D1D1"
        android:id="@+id/gray_line"
        android:layout_centerHorizontal="true"
        android:layout_below="@+id/journey_custome_layout_card_view_generic_transportation_mode_container"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="true" />

    <LinearLayout
        android:id="@+id/journey_custome_layout_card_view_extra_info_container"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:animateLayoutChanges="true"
        android:layout_below="@+id/gray_line"
        android:layout_alignRight="@+id/linearLayout"
        android:layout_alignEnd="@+id/linearLayout">

    </LinearLayout>

</RelativeLayout>

I'm also using custom ViewGroup, here is the code for it . /* * Modified version * GitHub fork: https://github.com/dlukashev/AndroidSlidingUpPanel \ diff: https://github.com/dlukashev/AndroidSlidingUpPanel/commit/e7edb89af96a760423d5d00342ad237d78b75b85

gabrielemariotti commented 10 years ago

You are missing a step. https://github.com/gabrielemariotti/cardslib/blob/master/doc/OVERVIEW.md

You have first to define the global layout which define the single areas. You can of course use a layout with the only main area if you doesn't need the others. The layout written above is ok, but it should be the inner layout in main area. Card card = new Card( context, R.layout.journey_custom_layout_card_view_generic);