Use attribute animation to implement Youku menu for your reference. The specific content is as follows
Layout file
<RelativeLayout xmlns:andro xmlns:tools="/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" > <RelativeLayout android:layout_width="280dip" android:layout_height="140dip" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android: android:background="@drawable/level3" > <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="6dip" android:layout_marginLeft="12dip" android:background="@drawable/channel1" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/c1" android:layout_marginBottom="12dip" android:layout_marginLeft="28dip" android:background="@drawable/channel2" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/c2" android:layout_marginBottom="6dip" android:layout_marginLeft="8dip" android:layout_toRightOf="@id/c2" android:background="@drawable/channel3" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_margin="6dip" android:background="@drawable/channel4" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/c6" android:layout_marginBottom="6dip" android:layout_marginRight="8dip" android:layout_toLeftOf="@+id/c6" android:background="@drawable/channel5" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@+id/c7" android:layout_marginBottom="12dip" android:layout_marginRight="28dip" android:layout_alignParentRight="true" android:background="@drawable/channel6" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="6dip" android:layout_marginRight="12dip" android:layout_alignParentRight="true" android:background="@drawable/channel7" /> </RelativeLayout> <RelativeLayout android:layout_width="180dip" android:layout_height="90dip" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android: android:background="@drawable/level2" > <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_margin="10dip" android:background="@drawable/icon_search" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_margin="6dip" android:background="@drawable/icon_menu" /> <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_alignParentRight="true" android:layout_margin="10dip" android:background="@drawable/icon_myyouku" /> </RelativeLayout> <RelativeLayout android:layout_width="100dip" android:layout_height="50dip" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:background="@drawable/level1" > <ImageButton android: android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:background="@drawable/icon_home" /> </RelativeLayout> </RelativeLayout>
Core code
package ; import ; import ; import ; import ; import ; import ; import ; import ; import ; import ; /** * Created by Administrator on 2017.06.07.0007. */ public class YoukuMenu extends BasePager { @InjectView(.c1) ImageButton c1; @InjectView(.c2) ImageButton c2; @InjectView(.c3) ImageButton c3; @InjectView(.c4) ImageButton c4; @InjectView(.c5) ImageButton c5; @InjectView(.c6) ImageButton c6; @InjectView(.c7) ImageButton c7; @InjectView(.level3) RelativeLayout level3; @InjectView() ImageButton search; @InjectView() ImageButton menu; @InjectView() ImageButton myyouku; @InjectView(.level2) RelativeLayout level2; @InjectView() ImageButton home; private boolean isLeve12 = true; private boolean isLeve13 = true; public YoukuMenu(Context context) { super(context); } @Override public View initView() { View view = (mContext, .fragment_youku, null); (this,view); return view; } @Override public void initData() { //Set click event for the button (new MyOnClickLisetner()); (new MyOnClickLisetner()); } class MyOnClickLisetner implements { @Override public void onClick(View v) { switch (()){ case : // When clicking the home button, the animation effect begins if (isLeve12){ isLeve12 = false; (level2); if (isLeve13){ isLeve13 = false; (level3,200); } }else { isLeve12 = true; (level2); } break; case : if (isLeve13){ isLeve13 = false; (level3); }else { isLeve13 = true; (level3); } break; } } } }
Animation tools
package ; import ; import ; import ; import ; import ; import ; /** * Created by Administrator on 2017.06.07.0007. */ public class Tools { //Hide layoutpublic static void hide(ViewGroup view) { hide(view, 0); } //Show layoutpublic static void show(ViewGroup view) { //Use attribute animation to realize menu rotation ObjectAnimator animator = (view,"rotation",180,360); //Set the animation duration (300); (); (()/2); (()); } //Delay Hidepublic static void hide(ViewGroup view, int i) { ObjectAnimator animator = (view,"rotation",0,180); //Set the animation duration (300); //Set delay (i); (); (()/2); (()); } }
Source code:Android uses attribute animation to implement Youku menu
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.