0

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

4

1 回答 1

1

我不建议为元素设置固定位置,因为它只会让你的生活更难适应不同的屏幕尺寸。

使用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将始终绑定到其父母的右侧。这是通过在 上设置来实现android:layout_alignParentRight="true"ImageView

希望能帮助到你。

于 2010-11-07T19:42:23.930 回答