Skip to content

Instantly share code, notes, and snippets.

@IanField90
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IanField90/3c063e891e573810c6c8 to your computer and use it in GitHub Desktop.
Save IanField90/3c063e891e573810c6c8 to your computer and use it in GitHub Desktop.
Android Wear
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<alpha android:fromAlpha="0"
android:toAlpha="1"
android:duration="4000" />
</set>
public class MyActivity extends Activity {
private TextView mTextView;
private ImageView mLogo;
private ImageView mStars;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_my);
final WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
@Override
public void onLayoutInflated(WatchViewStub stub) {
mTextView = (TextView) stub.findViewById(R.id.text);
mLogo = (ImageView) stub.findViewById(R.id.logo);
Animation fadeIn = AnimationUtils.loadAnimation(MyActivity.this, R.anim.fade_in);
mLogo.startAnimation(fadeIn);
Animation springUp = AnimationUtils.loadAnimation(MyActivity.this, R.anim.spring_up);
mTextView.startAnimation(springUp);
mStars = (ImageView) stub.findViewById(R.id.stars);
RotateAnimation rotate = new RotateAnimation(0f, 360f,
(float) (getResources().getDisplayMetrics().heightPixels / 2),
(float) (getResources().getDisplayMetrics().widthPixels / 2));
rotate.setInterpolator(new LinearInterpolator());
rotate.setRepeatCount(Animation.INFINITE);
rotate.setDuration(5000);
AnimationSet animationSet = new AnimationSet(MyActivity.this, null);
animationSet.addAnimation(rotate);
animationSet.addAnimation(fadeIn);
mStars.setAnimation(animationSet);
}
});
}
}
<?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=".MyActivity"
android:background="#34263D"
tools:deviceIds="wear_square">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/white_stars"
android:id="@+id/stars"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/conjure_logo"
android:layout_centerInParent="true"
android:id="@+id/logo"
/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_round"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
/>
</RelativeLayout>
<?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=".MyActivity"
android:background="#34263D"
tools:deviceIds="wear_round">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/white_stars"
android:id="@+id/stars"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/conjure_logo"
android:layout_centerInParent="true"
android:id="@+id/logo"
/>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_round"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="25dp"
/>
</RelativeLayout>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android" android:interpolator="@android:interpolator/overshoot">
<translate android:fromYDelta="100"
android:toYDelta="0"
android:duration="400"
android:startOffset="2000" />
</set>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment