63. Layout layouts with transition animation effect

Source: Internet
Author: User

Below, down to see a demo of the effect, the code is as follows:

<Framelayoutxmlns:android= "Http://schemas.android.com/apk/res/android"Xmlns:app= "Http://schemas.android.com/apk/res-auto"Android:id= "@+id/root_layout"Android:layout_width= "Match_parent"Android:layout_height= "Match_parent"android:orientation= "vertical">    <Android.support.design.widget.FloatingActionButtonAndroid:id= "@+id/fab_btn"Android:layout_width= "Wrap_content"Android:layout_height= "Wrap_content"android:layout_gravity= "Bottom|right"Android:layout_margin= "10DP"android:src= "@drawable/ic_launcher"app:fabsize= "normal"/></Framelayout>
1 ImportAndroid.os.Bundle;2 ImportAndroid.support.design.widget.FloatingActionButton;3 ImportAndroid.support.design.widget.Snackbar;4 Importandroid.support.v7.app.AppCompatActivity;5 ImportAndroid.view.View;6 Importandroid.widget.FrameLayout;7  9  Public classMainActivity2extendsappcompatactivity {One  private Floatingactionbutton fab_btn = null;  A Private Framelayout root_layout = null;  -  - @Override the     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); - Setcontentview (r.layout.activity_main2); -  +         Root_layout = (framelayout) This. Findviewbyid (r.id.root_layout); -FAB_BTN = (Floatingactionbutton) This. Findviewbyid (R.ID.FAB_BTN); +Fab_btn.setonclicklistener (NewView.onclicklistener () { A @Override at              Public voidOnClick (View v) { -Snackbar.make (Root_layout, "I'm out.", Snackbar.length_long) -. setaction ("Know It",NewView.onclicklistener () { - @Override -                      Public voidOnClick (View v) { -  in                     } - }). Show (); +             } -         }); *     }Panax Notoginseng}

As shown, the problem comes out, the bottom of the bounce out of the small floating circle to block . There's a problem with that. So it needs to be modified again.

Modify the code as follows:

1  <android.support.design.widget.CoordinatorLayout 2     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     <Android.support.design.widget.FloatingActionButton9         Android:id= "@+id/fab_btn"Ten Android:layout_width= "Wrap_content" One Android:layout_height= "Wrap_content" A android:layout_gravity= "Bottom|right" - Android:layout_margin= "10DP" - android:src= "@drawable/ic_launcher" the app:fabsize= "normal"/> -  </android.support.design.widget.CoordinatorLayout> 

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.view.View;9 Ten  One  Public classMainActivity2extendsappcompatactivity { -     PrivateFloatingactionbutton fab_btn =NULL; -      Private coordinatorlayout root_layout = null;  the  - @Override -     protected voidonCreate (Bundle savedinstancestate) { -         Super. OnCreate (savedinstancestate); + Setcontentview (r.layout.activity_main2); -  +Root_layout = (Coordinatorlayout) This. Findviewbyid (r.id.root_layout); AFAB_BTN = (Floatingactionbutton) This. Findviewbyid (R.ID.FAB_BTN); atFab_btn.setonclicklistener (NewView.onclicklistener () { - @Override -              Public voidOnClick (View v) { -Snackbar.make (Root_layout, "I'm out.", Snackbar.length_long) -. setaction ("Know It",NewView.onclicklistener () { - @Override in                              Public voidOnClick (View v) { to                             } + }). Show (); the             } *         });Panax Notoginseng     } the}

Now the effect will not be blocked, just need to change the outermost framelayout to Coordinatorlayout can be, very convenient.

63. Layout layouts with transition animation effect

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.