Android Properties Animation app, do not know this effect good-looking, anyway quite fun!

Source: Internet
Author: User
Tags gety

Two days ago in order to see Comics, downloaded an animation app, open a look, sliding unexpectedly below the tab with the above Titel are hidden, into full-screen, feel good to look like oh, I thought it was hidden with the reality of the property that, then a careful look, not, then only the animation to achieve, It also seems to be done with attribute animations: Property Animations Change the properties of an object. Do not know this effect is not good, should be suitable for some full-screen reading class app.

Let's see how it works:


Look at the effect we have:


Well, the code is very rare to achieve this effect:

Package Com.example.hidetitle;import Android.annotation.suppresslint;import Android.app.activity;import Android.os.bundle;import Android.view.motionevent;import Android.view.view;import Android.view.viewpropertyanimator;import Android.view.view.ontouchlistener;import Android.widget.ArrayAdapter; Import Android.widget.linearlayout;import Android.widget.listview;public class Mainactivity extends Activity {private Boolean ismove = True;private viewpropertyanimator animatebottom,animatetop; @SuppressLint ("Newapi") @ overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview ( R.layout.activity_main); ListView Mlistview = (ListView) Findviewbyid (R.id.my_listview); LinearLayout Tabbottom = (linearlayout) Findviewbyid (R.id.tabbottom); LinearLayout tabtop = (linearlayout) Findviewbyid (r.id.tabtop); animatebottom = Tabbottom.animate (); animatetop = Tabtop . Animate (); arrayadapter<string> adapter = new Arrayadapter<string> (this,android. R.layOut.simple_expandable_list_item_1); for (int i = 0; i <; i++) {Adapter.add (i + "");} Mlistview.setadapter (adapter); Mlistview.setontouchlistener (new Ontouchlistener () {Private float Y;private Boolean down = true;private float lasty; @Overridepublic boolean OnTouch (View V, motionevent event) {switch (event.getaction ()) {CA Se motionevent.action_down:y = event.gety (); if (down) {lasty = y;} Down = false;break;case Motionevent.action_move:break;case MotionEvent.ACTION_UP:down = true;if (Lasty-event.gety () & Lt -5) {onscrollreset ();} else if (Lasty-event.gety () > 5) {onscroll ();} break;} return false;}}); @SuppressLint ("Newapi") public void onscroll () {if (ismove) {animatebottom.setduration (200); Animatetop.setduration ($). Translationy ( -200); ismove = false;}} @SuppressLint ("Newapi") public void Onscrollreset () {if (!ismove) {animatebottom.setduration (0); Animatetop.setduration ($). Translationy (0); ismove = True;}}}
Xml:

<framelayout xmlns:android= "http://schemas.android.com/apk/res/android" android:layout_width= "Fill_parent" android:layout_height= "Fill_parent" > <listview android:id= "@+id/my_listview" android:layout_width= "Match_parent" android:layout_height= "match_parent" > </ListView> <relativelayout android: Layout_width= "Match_parent" android:layout_height= "match_parent" > <linearlayout android:id = "@+id/tabbottom" android:layout_width= "match_parent" android:layout_height= "50dip" Andro            Id:layout_alignparentbottom= "true" android:background= "#880090D9" android:gravity= "center" android:orientation= "vertical" > <textview android:id= "@+id/textview1" an                Droid:layout_width= "Wrap_content" android:layout_height= "Wrap_content" android:text= "title" Android:textcolor="#ffffff" android:textsize= "18sp"/> </LinearLayout> <linearlayout            Android:id= "@+id/tabtop" android:layout_width= "match_parent" android:layout_height= "50dip"            Android:layout_alignparenttop= "true" android:background= "#880090D9" android:gravity= "center"                android:orientation= "vertical" > <textview android:layout_width= "wrap_content" android:layout_height= "Wrap_content" android:text= "title" Android:textcolor= "#ff FFFF "android:textsize=" 18sp "/> </LinearLayout> </relativelayout></framelayout >


Fun!


Android Properties Animation app, do not know this effect good-looking, anyway quite fun!

Related Article

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.