移动图像imageview

移动图像imageview

问题描述:

我有一个问题。我在XML ImageView中完成了。不幸的是,手机屏幕左侧的“搁置”。我希望这张照片可以转移到正确的位置。 我想指出图像的X和Y位置移动到指定的位置。 我该怎么做? 请详细解释,因为我是Java的新手程序员。 对不起,错误。我不是每天都用英语说。移动图像imageview

我不建议为元素设置固定位置,因为它会让您的生活更难以适应不同的屏幕尺寸。使用RelativeLayout。这里是你的XML如何看起来的例子。

<?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:id="@+id/imageview" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/icon" 
    android:layout_alignParentRight="true"/> 
</RelativeLayout> 

这种方式ImageView将永远绑定到其父母的右侧。这是通过在ImageView上设置android:layout_alignParentRight="true"来实现的。

希望它有帮助。