java - Implementing an adapter for RecyclerView in Android -
i trying implement flexible space image pattern of material design.
in order so, followed this tutorial.
the problem is, tutorial uses recyclerview
, , have view i'd use simple scrollview
relative view:
<scrollview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior"> <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingleft="20dp" android:paddingright="20dp" > <textview android:id="@+id/loggedintitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:layout_below="@+id/separator1" android:layout_marginleft="10dp" android:layout_margintop="15dp" android:text="@string/profile_logged_in_with_title" android:textsize="18sp" /> <imageview android:id="@+id/loggedinplatformlogo" android:layout_width="95dp" android:layout_height="30dp" android:layout_alignbottom="@+id/loggedintitle" android:layout_centerhorizontal="true" android:layout_marginbottom="-4dp" android:layout_marginleft="30dp" android:layout_torightof="@+id/loggedintitle" android:background="@drawable/facebook_logo" android:gravity="center_horizontal|center_vertical" /> <view android:id="@+id/separator2" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignleft="@+id/separator1" android:layout_below="@+id/loggedintitle" android:layout_margintop="17dp" android:background="@android:color/darker_gray" /> <imageview android:id="@+id/homeicon" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignleft="@+id/loggedintitle" android:layout_below="@+id/separator2" android:layout_margintop="10dp" android:background="@drawable/home_icon" /> <textview android:id="@+id/hometitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/homeicon" android:layout_marginbottom="4dp" android:layout_marginleft="15dp" android:layout_torightof="@+id/homeicon" android:text="@string/profile_home_title" android:textsize="18sp" android:textstyle="bold" /> <autocompletetextview android:id="@+id/homeaddressedit" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/homeicon" android:layout_below="@+id/homeicon" android:layout_margintop="2dp" android:ems="10" android:hint="@string/profile_home_address_hint" android:inputtype="textautocomplete" android:textsize="16sp" /> <view android:id="@+id/separator3" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignleft="@+id/separator1" android:layout_below="@+id/homeaddressedit" android:layout_margintop="8dp" android:background="@android:color/darker_gray" /> <imageview android:id="@+id/workicon" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignleft="@+id/homeicon" android:layout_below="@+id/separator3" android:layout_margintop="10dp" android:background="@drawable/work_icon" /> <textview android:id="@+id/worktitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/workicon" android:layout_marginbottom="4dp" android:layout_marginleft="15dp" android:layout_torightof="@+id/workicon" android:text="@string/profile_work_title" android:textsize="18sp" android:textstyle="bold" /> <autocompletetextview android:id="@+id/workaddressedit" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignleft="@+id/workicon" android:layout_below="@+id/workicon" android:layout_margintop="2dp" android:ems="10" android:hint="@string/profile_work_address_hint" android:inputtype="textautocomplete" android:textsize="16sp" /> <view android:id="@+id/separator4" android:layout_width="match_parent" android:layout_height="1dp" android:layout_alignleft="@+id/separator1" android:layout_below="@+id/workaddressedit" android:layout_margintop="8dp" android:background="@android:color/darker_gray" /> <imageview android:id="@+id/privacyicon" android:layout_width="30dp" android:layout_height="30dp" android:layout_alignleft="@+id/workicon" android:layout_below="@+id/separator4" android:layout_margintop="13dp" android:background="@drawable/privacy_icon" /> <textview android:id="@+id/privacytitle" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignbottom="@+id/privacyicon" android:layout_marginbottom="4dp" android:layout_marginleft="15dp" android:layout_torightof="@+id/privacyicon" android:text="@string/profile_privacy_title" android:textsize="18sp" android:textstyle="bold" /> <spinner android:id="@+id/privacyspinner" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignleft="@+id/privacyicon" android:layout_below="@+id/privacyicon" android:layout_marginbottom="4dp" android:layout_margintop="-3dp" android:entries="@array/profile_privacy_settings" android:prompt="@string/profile_privacy_title" /> </relativelayout> </scrollview>
so tried replace recyclerview in tutorial's layout xml reference view, result can't scroll view. i guess that's because scrollview
not compatible flexible space pattern.
next attempt trying convert above scrollview
layout adapter in order use recyclerview
following android developers example, have no idea how that, since got many elements combine , example consists of simple array of strings.
i'd appreciate sample of how adapter should in order match layout above, or easier solution (maybe recyclerview isn't best direction), if exists.
there's design support library google. try website: http://hmkcode.com/material-design-app-android-design-support-library-appcompat/
Comments
Post a Comment