64. Layout layouts with transition animation effect (2)

Source: Internet
Author: User

"A sliding view of the perfect combination of coordinatorlayout-and gestures"

"appbarlayout-can slide AppBar."

1 <Android.support.design.widget.CoordinatorLayout2     xmlns:android= "Http://schemas.android.com/apk/res/android"3 Xmlns:app= "Http://schemas.android.com/apk/res-auto"4 Android:id= "@+id/root_layout"5 Android:layout_width= "Match_parent"6 Android:layout_height= "Match_parent"7 android:orientation= "vertical">8 9     <Android.support.design.widget.AppBarLayoutTen         Android:layout_width= "Match_parent" One Android:layout_height= "Wrap_content"> A  -         <!-- - use Toolbar as a title bar the  - app:layout_scrollflags= "Scroll|enteralways": - As you move up, the toolbar will move out of the screen, and as soon as you swipe down, the toolbar will appear.  -  + app:layout_scrollflags= "scroll|enteralwayscollapsed": - When you move up, toolbar will move out of the screen, swipe down, and slide to the first to show toolbar.  +  A app:layout_scrollflags= "scroll|exituntilcollapsed": at no matter whether you move up or down, toolbar will not slide out of the screen.  - also: If added, android:minheight= "20DP" when.  - when you swipe up, the toolbar moves out of the screen until it becomes the minimum height, - when you swipe down, the toolbar is displayed when you swipe to the first one -          - -         <Android.support.v7.widget.Toolbar in             Android:id= "@+id/toolbar" - Android:layout_width= "Match_parent" to Android:layout_height= "? Attr/actionbarsize" + Android:background= "#77db93" - Android:minheight= "20DP" the App:popuptheme= "@style/themeoverlay.appcompat.light" * App:layout_scrollflags= "scroll|exituntilcollapsed" /> $     </Android.support.design.widget.AppBarLayout>Panax Notoginseng  -     <!--a sliding view that perfectly combines with gestures - the     <Android.support.v4.widget.NestedScrollView +         Android:layout_width= "Match_parent" A Android:layout_height= "Match_parent" the App:layout_behavior= "@string/appbar_scrolling_view_behavior"> +         <LinearLayout -             Android:layout_width= "Match_parent" $ Android:layout_height= "Wrap_content" $ android:orientation= "vertical"> -             <ImageView -                 Android:layout_width= "Wrap_content" the Android:layout_height= "Wrap_content" - android:src= "@drawable/ic_launcher" />Wuyi             ............ the             <ImageView -                 Android:layout_width= "Wrap_content" Wu Android:layout_height= "Wrap_content" - android:src= "@drawable/ic_launcher" /> About         </LinearLayout> $     </Android.support.v4.widget.NestedScrollView> -  -     <Android.support.design.widget.FloatingActionButton -         Android:id= "@+id/fab_btn" A Android:layout_width= "Wrap_content" + Android:layout_height= "Wrap_content" the android:layout_gravity= "Bottom|right" - Android:layout_margin= "10DP" $ android:src= "@drawable/ic_launcher" the app:fabsize= "normal" /> the </Android.support.design.widget.CoordinatorLayout>

1 <Resources>2     <!--Values/styles.xml -3     <stylename= "Apptheme"Parent= "Theme.AppCompat.Light.DarkActionBar">4         <!--Customize your theme here. -5         <Itemname= "Android:windowactionbar">False</Item>6         <Itemname= "Android:windownotitle">True</Item>7         <Itemname= "Windowactionbar">False</Item>8         <Itemname= "Windownotitle">True</Item>9     </style>Ten </Resources>
1  PackageCom.example.com.designdemo;2 3 ImportAndroid.os.Bundle;4 Importandroid.support.design.widget.CoordinatorLayout;5 ImportAndroid.support.design.widget.FloatingActionButton;6 ImportAndroid.support.design.widget.Snackbar;7 Importandroid.support.v7.app.AppCompatActivity;8 ImportAndroid.support.v7.widget.Toolbar;9 ImportAndroid.view.View; One  A  Public classMainActivity2extendsappcompatactivity { -     PrivateFloatingactionbutton fab_btn =NULL; the     PrivateCoordinatorlayout root_layout =NULL; -     PrivateToolbar Toolbar =NULL; -  - @Override +     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.activity_main2); A  attoolbar = (Toolbar) This. Findviewbyid (R.id.toolbar); - Setsupportactionbar (toolbar); -  -Root_layout = (coordinatorlayout) This. Findviewbyid (r.id.root_layout); -FAB_BTN = (Floatingactionbutton) This. Findviewbyid (R.ID.FAB_BTN); -Fab_btn.setonclicklistener (NewView.onclicklistener () { in @Override -              Public voidOnClick (View v) { toSnackbar.make (Root_layout, "I'm out.", Snackbar.length_long) +. setaction ("Know It",NewView.onclicklistener () { - @Override the                              Public voidOnClick (View v) { $                             }Panax Notoginseng }). Show (); the             } +         }); A  the     } -}

Use Toolbar as a title bar

App:layout_scrollflags= "Scroll|enteralways":
As you move up, the toolbar will move out of the screen, and as soon as you swipe down, the toolbar will appear.

App:layout_scrollflags= "scroll|enteralwayscollapsed":
When you move up, toolbar will move out of the screen, swipe down, and slide to the first to show toolbar.

App:layout_scrollflags= "scroll|exituntilcollapsed":
No matter whether you move up or down, toolbar will not slide out of the screen.
also: If added,android:minheight= "20DP" when. When you swipe up, the toolbar moves out of the screen until it becomes the minimum height,
When you swipe down, the toolbar is displayed when you swipe to the first one

"Collapsing toolbars-can stretch the toolbar"

64. Layout layouts with transition animations (2)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.