<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Yinan Oliver on Medium]]></title>
        <description><![CDATA[Stories by Yinan Oliver on Medium]]></description>
        <link>https://medium.com/@ChloeL?source=rss-28973e43ff86------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ybwjgiT40kiQsEEW.jpg</url>
            <title>Stories by Yinan Oliver on Medium</title>
            <link>https://medium.com/@ChloeL?source=rss-28973e43ff86------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 14:19:46 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ChloeL/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RecyclerView and ListView]]></title>
            <link>https://medium.com/@ChloeL/recyclerview-and-listview-b98b430227fd?source=rss-28973e43ff86------2</link>
            <guid isPermaLink="false">https://medium.com/p/b98b430227fd</guid>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Yinan Oliver]]></dc:creator>
            <pubDate>Thu, 14 Jul 2016 20:18:37 GMT</pubDate>
            <atom:updated>2016-07-14T20:18:37.449Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>So, RecyclerView was added in the Supporting Library since Google IO 2014. What is exactly different from RecyclerView and ListView? We all know RecyclerView implements ViewHolder pattern. So Android can cache the items that are invisible, reuse the list item layout to ensure smooth scrolling and 16ms gold rule.</blockquote><h4>What’s more?</h4><p>First of all, let’s look at some important components related to implementing a RecyclerView</p><ul><li><strong>RecyclerView.Adapter</strong> — binds views with data.</li><li><strong>ViewHolder </strong>— holds all the views that are needed to bind data.</li><li><strong>LayoutManager </strong>— is responsible for laying out UI.</li><li><strong>ItemDecoration</strong> — is used to draw item separators.</li><li><strong>ItemAnimator</strong> — adds animations to an item view, e.g. animation when adding/deleting a list item.</li></ul><h4><strong>Differences between ListView and RecyclerView</strong></h4><ul><li>ViewHolder pattern is not required for a ListView Adapter, but one or more ViewHolder is <strong><em>required</em></strong> for RecyclerView.</li><li>Custom list item view layout — ListView only supports vertically item layouts. RecyclerView is more flexible to customize the layout experience, e.g. horizontal scrolling list or <a href="https://guides.codepath.com/android/Heterogenous-Layouts-inside-RecyclerView">heterogeneous layouts</a>.</li><li>Item animations. — Using RecyclerView is much easier to create animation of each item view. For example, creating animation when adding/deleting items can be achieved overriding class <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.ItemAnimator.html"><strong>RecyclerView.ItemAnimator</strong></a>.</li><li>Setting data source — ListView requires using different Adapters based on the data type. For example, ArrayAdapter can be used to process an array or an ArrayList. CursorAdapter can deal with data from a Database. On the contrary, RecyclerView doesn’t provide different adapters, we have to override <a href="https://developer.android.com/reference/android/support/v7/widget/RecyclerView.Adapter.html%20to%20handle%20data"><strong>RecyclerView.Adapter</strong></a>.</li><li>Item separator appearance — Setting the<em> “android:divider”</em> can be used to set the appearance of ListView. Extending RecyclerView.ItemDecoration class can be used to customize the divider in RecyclerView. <strong>RecyclerView.ItemDecoration</strong> provides more freedom of customization than the “android:divider”.</li><li><strong><em>AdapterView.OnItemClickListener </em></strong>— ListView wins in this round. There’s no OnItemClickListener interface in RecyclerView. <a href="http://sapandiwakar.in/recycler-view-item-click-handler/">RecyclerView.OnItemTouchListener</a> that we can work around to respond to a click motion.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b98b430227fd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CoordinatorLayout and Behavior]]></title>
            <link>https://medium.com/@ChloeL/something-coordinatorlayout-and-behavior-892016efc9a2?source=rss-28973e43ff86------2</link>
            <guid isPermaLink="false">https://medium.com/p/892016efc9a2</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Yinan Oliver]]></dc:creator>
            <pubDate>Wed, 13 Jul 2016 07:33:47 GMT</pubDate>
            <atom:updated>2016-07-14T04:36:22.191Z</atom:updated>
            <content:encoded><![CDATA[<p>At this year’s Google I/O, there was a ‘powerful’ UI component introduced in the <a href="http://android-developers.blogspot.com/2015/05/android-design-support-library.html">new Design Supporting Library</a>, <a href="https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.html"><strong>CoordinatorLayout</strong></a><strong>. </strong>Like its name, the layout is used to coordinate dependencies between its child views. Another interesting that is associated with CoordinatorLayout is <a href="https://developer.android.com/reference/android/support/design/widget/CoordinatorLayout.Behavior.html"><strong>Behavior</strong></a>. Behavior tells child view how to behave as expected when you swipe, scroll etc.</p><h4>Create a custom Behavior</h4><p>Import supporting library in the build.gradle file.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c0d81e23fa9fc7f8894d0d00994c3603/href">https://medium.com/media/c0d81e23fa9fc7f8894d0d00994c3603/href</a></iframe><p>First of all, Behavior only works for the direct child views inside a CoordinatorLayout. In this example, we’re creating a second view that will follow the first will on scrolling. So the first thing to do is to specify the dependency relationship between two view.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f11938cd92adbc22543f483f9da21710/href">https://medium.com/media/f11938cd92adbc22543f483f9da21710/href</a></iframe><p>CoordinatorLayout will traverse all its child views to see what Behaviors are depended on the views. When the View changes, the callback methods inside the Behavior also got triggered. <em>If the Behavior changes the child view’s size or position, it should return true. The default implementation returns false.</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e5930a4c3427fb34c07ad6e60b3e09a6/href">https://medium.com/media/e5930a4c3427fb34c07ad6e60b3e09a6/href</a></iframe><h4>Example 1</h4><blockquote>Declare the behavior behavior in style.xml</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c282307ca0d5052e225238acd3b50a1b/href">https://medium.com/media/c282307ca0d5052e225238acd3b50a1b/href</a></iframe><blockquote>Create custom Behavior</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0aa295b5eecf44eb7dc1e62dfbcbbb92/href">https://medium.com/media/0aa295b5eecf44eb7dc1e62dfbcbbb92/href</a></iframe><blockquote>The layout.xml</blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a065780f27d15941fabede042935ab52/href">https://medium.com/media/a065780f27d15941fabede042935ab52/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*1yjPyt_HG4hXBVQKFrGAAA.gif" /><figcaption>Final result. 2nd view follows 1st view on scrolling the 1st view.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=892016efc9a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>