{"id":256301,"date":"2015-04-29T14:14:02","date_gmt":"2015-04-29T10:14:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=256301"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=256301","title":{"rendered":"SwipeRefreshLayout: \u043d\u0435 \u0441\u0444\u0435\u0440\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0438 \u043d\u0435 \u0432 \u0432\u0430\u043a\u0443\u0443\u043c\u0435"},"content":{"rendered":"<p> \t\t\t\u041f\u0440\u043e \u043d\u043e\u0432\u044b\u0439 <a href=\"http:\/\/developer.android.com\/reference\/android\/support\/v4\/widget\/SwipeRefreshLayout.html\">SwipeRefreshLayout<\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Android support \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/218365\/\">\u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b\u0438<\/a>, \u0434\u0430 \u0438 Google \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0432\u044b\u0434\u0430\u0451\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b. \u0418\u0445 \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043e\u0434\u043d\u043e \u2014 \u0432 SwipeRefreshLayout \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 TextView \u0438\u043b\u0438 ListView, \u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u043d\u0443\u0442\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441 \u0443\u043c\u0438\u043b\u0435\u043d\u0438\u0435\u043c \u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0447\u0443\u0442\u044c \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043d\u0430\u0434\u043e?<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c Activity \u0441 \u0434\u0432\u0443\u043c\u044f \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c\u0438: \u0441\u0432\u0435\u0440\u0445\u0443 \u2014 \u043f\u0430\u043d\u0435\u043b\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u0441\u043d\u0438\u0437\u0443 \u2014 \u043d\u0435\u043a\u043e\u0435 View (\u043b\u0438\u0448\u043d\u0438\u0435 \u0442\u0435\u0433\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u044b):<\/p>\n<pre><code class=\"xml\">&lt;LinearLayout android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot;     android:orientation=&quot;vertical&quot; &gt;     &lt;fragment         android:layout_width=&quot;match_parent&quot;         android:layout_height=&quot;wrap_content&quot; \/&gt;     &lt;com.mycompany.MyView         android:layout_width=&quot;match_parent&quot;         android:layout_height=&quot;match_parent&quot; \/&gt; &lt;\/LinearLayout&gt; <\/code><\/pre>\n<p>  \u041d\u0430\u043c \u0432\u0441\u0435\u0433\u043e-\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c LinearLayout \u043d\u0430 SwipeRefreshLayout. \u0422\u043e\u0447\u043d\u0435\u0435, \u043f\u0440\u043e\u0441\u0442\u043e \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u2014 SwipeRefreshLayout \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0434\u0438\u043d \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0431\u0435\u0440\u043d\u0451\u043c LinearLayout \u0432 SwipeRefreshLayout:<\/p>\n<pre><code class=\"xml\">&lt;android.support.v4.widget.SwipeRefreshLayout     android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot; &gt;     &lt;LinearLayout android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot;     android:orientation=&quot;vertical&quot; &gt;         &lt;fragment         android:layout_width=&quot;match_parent&quot;         android:layout_height=&quot;wrap_content&quot; \/&gt;         &lt;com.mycompany.MyView         android:layout_width=&quot;match_parent&quot;         android:layout_height=&quot;match_parent&quot; \/&gt;     &lt;\/LinearLayout&gt; &lt;\/android.support.v4.widget.SwipeRefreshLayout&gt; <\/code><\/pre>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u2014 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442! \u041f\u0440\u0430\u0432\u0434\u0430, \u043a\u0430\u043a-\u0442\u043e \u0441\u0442\u0440\u0430\u043d\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442: \u0438\u043d\u0434\u0438\u043a\u0430\u0442\u043e\u0440 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0442\u043e \u043d\u0435 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f, \u0442\u043e \u043f\u0440\u043e\u043f\u0430\u0434\u0430\u0435\u0442.<\/p>\n<p>  \u041c\u0430\u0442\u0435\u0440\u0438\u043c\u0441\u044f, \u0433\u0443\u0433\u043b\u0438\u043c, \u0438\u0437\u0443\u0447\u0430\u0435\u043c \u043e\u043f\u044b\u0442 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0445 \u043f\u043e\u043a\u043e\u043b\u0435\u043d\u0438\u0439. \u041e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f, \u0432 SwipeRefreshLayout \u0447\u0442\u043e \u043f\u043e\u043f\u0430\u043b\u043e \u043a\u043b\u0430\u0441\u0442\u044c \u043d\u0435\u043b\u044c\u0437\u044f. <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ScrollView.html\">ScrollView<\/a> \u043c\u043e\u0436\u043d\u043e, <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/GridView.html\">GridView<\/a> \u043c\u043e\u0436\u043d\u043e, <a href=\"http:\/\/developer.android.com\/reference\/android\/widget\/ListView.html\">ListView<\/a> \u043c\u043e\u0436\u043d\u043e, \u0430 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0438\u0447\u0435\u0433\u043e \u0438 \u043d\u0435\u043b\u044c\u0437\u044f. ListView \u0438 GridView \u043d\u0430\u043c \u0441\u043e\u0432\u0441\u0435\u043c \u043d\u0435 \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0442, \u0430 \u0432\u043e\u0442 ScrollView \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c. \u041e\u0431\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u043c \u043d\u0430\u0448 \u043c\u043d\u043e\u0433\u043e\u0441\u0442\u0440\u0430\u0434\u0430\u043b\u044c\u043d\u044b\u0439 LinearLayout \u0432 ScrollView:<\/p>\n<pre><code class=\"xml\">&lt;android.support.v4.widget.SwipeRefreshLayout      android:layout_width=&quot;match_parent&quot;     android:layout_height=&quot;match_parent&quot; &gt;     &lt;ScrollView         android:layout_width=&quot;match_parent&quot;         android:layout_height=&quot;match_parent&quot; &gt;         &lt;LinearLayout             android:layout_width=&quot;match_parent&quot;             android:layout_height=&quot;wrap_content&quot;             android:orientation=&quot;vertical&quot; &gt;             &lt;fragment android:layout_width=&quot;match_parent&quot;                 android:layout_height=&quot;wrap_content&quot; \/&gt;             &lt;com.mycompany.MyView                 android:layout_width=&quot;match_parent&quot;                 android:layout_height=&quot;match_parent&quot; \/&gt;         &lt;\/LinearLayout&gt;     &lt;\/ScrollView&gt; &lt;\/android.support.v4.widget.SwipeRefreshLayout&gt; <\/code><\/pre>\n<p>  \u041e\u0431\u0440\u0430\u0449\u0430\u0435\u043c \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u2014 <a href=\"https:\/\/developer.android.com\/tools\/help\/lint.html\">Lint<\/a> \u0442\u0443\u0442 \u0436\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c android:layout_height \u0441 match_parent \u043d\u0430 wrap_content \u0443 \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0432 ScrollView \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  \u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c, \u0438\u2026 \u0432\u0438\u0434\u0438\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0430\u043d\u0435\u043b\u044c \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u0410 \u0433\u0434\u0435 \u0436\u0435 \u043d\u0438\u0436\u043d\u0438\u0439 View? \u0410 \u043d\u0435\u0442 \u0435\u0433\u043e. \u0422\u043e\u0447\u043d\u0435\u0435, \u043e\u043d \u0435\u0441\u0442\u044c, \u043d\u043e \u043c\u044b \u0435\u0433\u043e \u043d\u0435 \u0432\u0438\u0434\u0438\u043c. \u0420\u0430\u043d\u044c\u0448\u0435 LinearLayout \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u043b \u0435\u0433\u043e \u043d\u0430 \u0432\u0441\u0451 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f match_parent, \u043d\u043e \u0442\u0435\u043f\u0435\u0440\u044c-\u0442\u043e \u043c\u044b \u0432\u043d\u0443\u0442\u0440\u0438 ScrollView! \u0410 ScrollView \u043f\u043e\u0442\u043e\u043c\u0443 \u0438 ScrollView, \u0447\u0442\u043e \u043d\u0438\u043a\u043e\u0433\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0435\u0431\u044f \u0440\u0430\u0441\u0442\u044f\u0433\u0438\u0432\u0430\u0442\u044c \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0435\u0433\u043e \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430 \u043f\u0440\u0435\u0434\u0435\u043b\u044b \u0441\u0430\u043c\u043e\u0433\u043e ScrollView.<\/p>\n<p>  \u0412\u044b\u0445\u043e\u0434 \u2014 \u043d\u0430\u0448\u0435 \u043d\u0438\u0436\u043d\u0435\u0435 MyView \u0434\u043e\u043b\u0436\u043d\u043e \u0441\u0430\u043c\u043e \u0441\u0435\u0431\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0442\u043e \u0435\u0441\u0442\u044c \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u0441\u0432\u043e\u044e \u0432\u044b\u0441\u043e\u0442\u0443, \u043e\u0441\u043d\u043e\u0432\u044b\u0432\u0430\u044f\u0441\u044c \u043d\u0430 \u0432\u044b\u0441\u043e\u0442\u0435 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e Activity:<\/p>\n<pre><code class=\"java\">@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { \tViewParent llp = getParent(); \/\/ LinearLayout \tView swp = (View) llp.getParent(); \/\/ ScrollView \tView srlp = (View) swp.getParent(); \/\/ SwipeRefreshLayout  \tint measuredWidth = getDefaultSize(getSuggestedMinimumWidth(), \t\twidthMeasureSpec); \tint measuredHeight = srlp.getMeasuredHeight(); \tint orientation = getResources().getConfiguration().orientation; \tif (orientation == Configuration.ORIENTATION_PORTRAIT) { \t    View filter = swp.findViewById(R.id.frFilter); \t    int fh = filter.getMeasuredHeight(); \t    measuredHeight -= fh; \t} \tsetMeasuredDimension(measuredWidth, measuredHeight); } <\/code><\/pre>\n<p>  \u041e\u0447\u0435\u043d\u044c \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435. \u0417\u0430\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0413\u043b\u0430\u043c\u0443\u0440\u043d\u044b\u0445 \u0432\u0441\u0435\u043c \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0439! \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/256947\/\"> http:\/\/habrahabr.ru\/post\/256947\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p> \t\t\t\u041f\u0440\u043e \u043d\u043e\u0432\u044b\u0439 <a href=\"http:\/\/developer.android.com\/reference\/android\/support\/v4\/widget\/SwipeRefreshLayout.html\">SwipeRefreshLayout<\/a> \u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Android support \u043d\u0430 \u0425\u0430\u0431\u0440\u0435 <a href=\"http:\/\/habrahabr.ru\/post\/218365\/\">\u0443\u0436\u0435 \u043f\u0438\u0441\u0430\u043b\u0438<\/a>, \u0434\u0430 \u0438 Google \u043b\u044e\u0431\u0435\u0437\u043d\u043e \u0432\u044b\u0434\u0430\u0451\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b. \u0418\u0445 \u0432\u0441\u0435\u0445 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u0435\u0442 \u043e\u0434\u043d\u043e \u2014 \u0432 SwipeRefreshLayout \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435 TextView \u0438\u043b\u0438 ListView, \u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u043d\u0443\u0442\u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441 \u0443\u043c\u0438\u043b\u0435\u043d\u0438\u0435\u043c \u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e. \u0410 \u0435\u0441\u043b\u0438 \u043d\u0430\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0447\u0443\u0442\u044c \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435 \u043d\u0430\u0434\u043e?  <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-256301","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=256301"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/256301\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=256301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=256301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=256301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}