以下是Palabre
视图的SplashScreen:
https://play.google.com/store/apps/details?id=com.levelup.palabre
正如我们所看到的,在应用程序开始时,有一个带有图像动画的SplashScreen。
这就是我想要实现这种美丽的方式:):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/imgLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="@drawable/grand_canyon"/>
</RelativeLayout>
结果:
这个SplashActivity有一个全屏视图。所以,
我们如何能够像左侧或右侧的Palabre
一样移动此图像?
这个屏幕上Image的大小是多少?
修改
我也发现这是全屏图像视图: 在你的布局中:
android:scaleType = "centerCrop"
以及我们需要为此imageview添加动画?
由于
答案 0 :(得分:3)
我认为通过混合使用Scale和TranslateAnimation,你可以做到这一点。
另一个选择是使用AnimationSet(http://developer.android.com/reference/android/animation/AnimatorSet.html)
编辑:以下是ObjectAnimator的一些示例,其中包含几个动画,其中myView是您要设置动画的视图。检查此链接以获取有关动画属性(rotationX,rotationY等)http://developer.android.com/guide/topics/graphics/prop-animation.html#views
的说明 AnimatorSet animSet = new AnimatorSet();
animSet.playTogether(
ObjectAnimator.ofFloat(myView, "rotationX", 0, 360),
ObjectAnimator.ofFloat(myView, "rotationY", 0, 180),
ObjectAnimator.ofFloat(myView, "rotation", 0, -90),
ObjectAnimator.ofFloat(myView, "translationX", 0, 90),
ObjectAnimator.ofFloat(myView, "translationY", 0, 90),
ObjectAnimator.ofFloat(myView, "scaleX", 1, 1.5f),
ObjectAnimator.ofFloat(myView, "scaleY", 1, 0.5f),
ObjectAnimator.ofFloat(myView, "alpha", 1, 0.25f, 1)
);
animSet.setDuration(5000).start();
还要检查我是否以毫秒为单位设定了动画的持续时间。
如果您将API定位在11以下,请检查http://nineoldandroids.com/以在较旧的机器人上使用AnimatorSet。
希望这会对你有所帮助。
答案 1 :(得分:3)
我终于找到了它。它很漂亮:) 只需添加依赖项:
compile 'com.flaviofaria:kenburnsview:1.0.6'
和
XML布局:
<com.flaviofaria.kenburnsview.KenBurnsView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/img"
android:scaleType = "centerCrop"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/splash" />
Github: https://github.com/flavioarfaria/KenBurnsView
感谢FlávioFaria这个好图书馆。但是,它有一个问题,那就是,当图像转到另一边时,它就像一个错误或类似卡住的东西,我还找不到最好的解决方案。
答案 2 :(得分:0)
以下是我认为你应该做的事情
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/ic_splash" >
</RelativeLayout>