地方图象半屏幕边界内,外一半 [英] place image half inside screen bounds, half outside
问题描述
我需要位置的图像,它的一半是屏幕范围之外,但我无法弄清楚如何做到这一点。这是我在onFling旋转轮,如果有人想知道。
设置alignParentBottom为true,然后通过它在code半高抵消了形象是一种选择,但我更preFER做这一切在XML。
任何想法?
编辑:我被要求出示我的XML布局
<?XML版本=1.0编码=UTF-8&GT?;
<的RelativeLayout的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
>
< ImageView的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:SRC =@绘制/图标
/>
< / RelativeLayout的>
杉杉创建动画的XML与以下code:
<翻译
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:toXDelta = - 50%P
机器人:fromXDelta = - 50%P
机器人:toYDelta =50%P
机器人:fromYDelta =50%P
机器人:时间=1
机器人:fillAfter =真
>
< /翻译>
创建上面
在活动,并使用动画动画 动画transAnimation = AnimationUtils.loadAnimation(这一点,R.anim.image_out);
strart动画和图像将一半一半了:
circleView.startAnimation(transAnimation);
I need to position an image so that half of it is outside the screen bounds, but I can't figure out how to do it. It is a wheel that I rotate on onFling, if anyone wonders.
Setting alignParentBottom to true and then offsetting the image by half its height in the code is an option, but I would much prefer to do it all in the xml.
Any ideas?
Edit: I've been asked to show my xml layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
/>
</RelativeLayout>
Firs create animation xml with following code:
<translate
xmlns:android="http://schemas.android.com/apk/res/android"
android:toXDelta="-50%p"
android:fromXDelta="-50%p"
android:toYDelta="50%p"
android:fromYDelta="50%p"
android:duration="1"
android:fillAfter="true"
>
</translate>
create animation in the Activity and use anim above
Animation transAnimation = AnimationUtils.loadAnimation(this, R.anim.image_out);
strart the animation and image will be half in half out:
circleView.startAnimation(transAnimation);
这篇关于地方图象半屏幕边界内,外一半的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!