Last active
May 18, 2021 03:00
-
-
Save sakurabird/6922697 to your computer and use it in GitHub Desktop.
(android)TextViewの文字をスクロールする。xmlでアニメーションを定義する。
右から文字が流れてきて一番左までマーキーしたら止まる。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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