[英]Need to Animate image button
I have my Android app with a login activity . 我的Android应用程序具有登录活动。 when the user gets logged in i need another activity which contains four image buttons and the main need is that when the activity comes up the buttons must slide to the middle from the right side .
当用户登录时,我需要另一个包含四个图像按钮的活动,而最主要的需求是,当该活动出现时, 按钮必须从右侧滑到中间。 Can anyone help me with the codes
谁能帮我的代码
Step 1.make anim folder and create xml with name slide_right.xml and put the below content 步骤1.make anim文件夹并创建名为slide_right.xml的xml并放入以下内容
<?xml version="1.0" encoding="utf-8"?>
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="100%p"
android:toXDelta="0"
android:duration="500" />
Step 2.Into the onCreate() method of your MainActivity class, load animation and set it to your view buttons 第2步。进入MainActivity类的onCreate()方法中,加载动画并将其设置为视图按钮
Animation animation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_right);
yourbutton.startAnimation(animation);
You can also use View Flipper 您也可以使用View Flipper
<ViewFlipper
android:id="@+id/myFlipper"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:animateFirstView="true"
android:autoStart="true"
android:flipInterval="500"
android:inAnimation="@android:anim/fade_in"
android:outAnimation="@android:anim/fade_out" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/myImage" />
</ViewFlipper>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.