在android中创建单个图像的循环平铺效果
我需要在android中开发单幅图像的循环平铺效果 参考应用程序:,他们正在导航抽屉中使用类似于循环平铺的效果 我尝试了动画(淡入/淡出),但我认为它与循环瓷砖效果不同 我在网上搜索了一下,但没有找到与android的Cycle Tile相关的内容在android中创建单个图像的循环平铺效果,android,Android,我需要在android中开发单幅图像的循环平铺效果 参考应用程序:,他们正在导航抽屉中使用类似于循环平铺的效果 我尝试了动画(淡入/淡出),但我认为它与循环瓷砖效果不同 我在网上搜索了一下,但没有找到与android的Cycle Tile相关的内容 请帮助。我创建了一个小演示来实现这个效果 我所做的是,在抽屉打开时,一个接一个地显示图像的动画 不需要缩放动画。我只使用了translateimation 以下是xml文件中的抽屉布局代码: <LinearLayout androi
请帮助。我创建了一个小演示来实现这个效果 我所做的是,在抽屉打开时,一个接一个地显示图像的动画 不需要缩放动画。我只使用了translateimation 以下是xml文件中的抽屉布局代码:
<LinearLayout
android:id="@+id/left_drawer_layout"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:orientation="vertical">
<ImageView
android:id="@+id/drawerImage"
android:contentDescription="@string/app_name"
android:layout_width="match_parent"
android:layout_height="140dip"
android:src="@drawable/ic_launcher"
android:adjustViewBounds="false"
android:cropToPadding="false"
android:scaleType ="centerCrop"
/>
<ListView
android:id="@+id/left_drawer"
android:layout_width="240dp"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:divider="@android:color/transparent"
android:dividerHeight="0dp"
android:background="#111"/>
</LinearLayout>
我正在将AnimationEnd中的x和y整数交换为反向。这意味着,第一个动画将从左上到右下显示,第二个动画将从相反方向显示<代码>图像编号增加,直到达到图像数组的长度。之后,它再次从0开始
如果你有任何疑问,请告诉我
这并不像那个应用程序那么流畅,但我希望它能帮助您继续:)它更像是您让我开心的一天。非常感谢:)这就是我要找的。工作得很有魅力。
//global initializations
private TypedArray imgs;
private int imageNumber = 0;
int x = 35;
int y = -35;
Animation animation;
//overriden method
public void onDrawerOpened(View drawerView) {
getActionBar().setTitle(mDrawerTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
showAnimatedImages();
}
//put in onCreate
imgs = getResources().obtainTypedArray(R.array.drawer_images);
//method to show animated images
public void showAnimatedImages(){
mDrawerImage.setImageResource(imgs.getResourceId(imageNumber, -1));
animation = new TranslateAnimation(x, y, x, y);
animation.setDuration(6000);
animation.setFillAfter(true);
mDrawerImage.startAnimation(animation);
animation.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationRepeat(Animation animation) {
// TODO Auto-generated method stub
}
@Override
public void onAnimationEnd(Animation animation) {
System.out.println(imageNumber);
System.out.println(imgs.length());
// TODO Auto-generated method stub
if(imageNumber > imgs.length())
imageNumber = 0;
else
imageNumber = imageNumber+1;
int r = x;
x = y;
y = r;
showAnimatedImages();
}
});
}