Skip to content

Instantly share code, notes, and snippets.

@sakurabird
Last active May 18, 2021 03:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sakurabird/6922697 to your computer and use it in GitHub Desktop.
Save sakurabird/6922697 to your computer and use it in GitHub Desktop.
(android)TextViewの文字をスクロールする。xmlでアニメーションを定義する。 右から文字が流れてきて一番左までマーキーしたら止まる。
package com.example.AnimationTest1;
import android.app.Activity;
import android.os.Bundle;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
public class AnimationTest1 extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Animation animation = AnimationUtils.loadAnimation(this, R.anim.myanimation);
findViewById(R.id.mytext).startAnimation(animation);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/mytext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="Animation Test qqqqqqqqqqqqqqqqqqqooooooooooooooo@@@@@@@@@" />
</LinearLayout>
<set xmlns:android="http://schemas.android.com/apk/res/android" >
<translate
android:duration="5000"
android:fromXDelta="100%p"
android:repeatCount="infinite"
android:repeatMode="restart"
android:toXDelta="0" />
<!-- <alpha android:fromAlpha="0.0" android:toAlpha="1.0" android:duration="300" /> -->
</set>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment