Skip to content

Instantly share code, notes, and snippets.

@MilesChou
Created April 2, 2014 07:46
Show Gist options
  • Save MilesChou/9929645 to your computer and use it in GitHub Desktop.
Save MilesChou/9929645 to your computer and use it in GitHub Desktop.
摩天輪動畫
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="net.polaris.fragment.QrCodeHistoryFragment">
<RelativeLayout
android:id="@+id/parent"
android:layout_centerInParent="true"
android:layout_width="200dp"
android:layout_height="30dp"
android:background="#F00">
<ImageView
android:id="@+id/child"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_margin="5dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#0CC"/>
</RelativeLayout>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromDegrees="0"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="359" />
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="2000"
android:fromDegrees="360"
android:interpolator="@android:anim/linear_interpolator"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="1" />
// ignore import
public class TestFragment extends Fragment
{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
{
return inflater.inflate(R.layout.fragment, container, false);
}
@Override
public void onViewCreated(View view, Bundle savedInstanceState)
{
View parent = view.findViewById(R.id.parent);
View child = view.findViewById(R.id.child);
Animation clock = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_clock);
Animation reverse = AnimationUtils.loadAnimation(getActivity(), R.anim.rotate_reverse);
parent.startAnimation(clock);
child.startAnimation(reverse);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment