简体   繁体   English

android将图像放置在所有屏幕的相同位置

[英]android place image in same place for all screens

Hi i got a image which contains some random circles on it. 嗨,我得到的图像上包含一些随机圆圈。 i want to place a view say imageview in the center of that. 我想在它的中心放置一个说imageview的视图。 The image is something like this 图像是这样的

[1] http://www.kirupa.com/html5/images/randomCircles.png [1] http://www.kirupa.com/html5/images/randomCircles.png

When the screen resolution changes the position of my imageview is also getting changed. 当屏幕分辨率更改时,我的imageview的位置也将更改。 I want to place them well for all resolutions. 我想将它们放置在所有分辨率下。

what i tried is 我试过的是

 <ImageView
    android:id="@+id/create"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_marginBottom="291dp"
    android:layout_marginRight="51dp"
    android:layout_toLeftOf="@+id/album"
    android:src="@drawable/create" />

<ImageView
    android:id="@+id/album"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/create"
    android:layout_centerHorizontal="true"
    android:src="@drawable/album" />

<ImageView
    android:id="@+id/imageView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@+id/existing"
    android:layout_alignParentLeft="true"
    android:layout_marginBottom="26dp"
    android:layout_marginLeft="34dp"
    android:src="@drawable/applogo" />

<ImageView
    android:id="@+id/demo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/album"
    android:layout_marginTop="95dp"
    android:layout_toRightOf="@+id/album"
    android:src="@drawable/demo" />

<ImageView
    android:id="@+id/existing"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerVertical="true"
    android:layout_toRightOf="@+id/demo"
    android:src="@drawable/existing" />

i know it is not right and don't know how to do it. 我知道这是不对的,也不知道该怎么做。 Please help me on this 请帮我

You need to Have the images of blue circles as well. 您还需要具有蓝色圆圈的图像。 There is no way you can have each ImageView exactly in the center of each circle with application running on different screens. 如果应用程序在不同的屏幕上运行,则无法使每个ImageView完全位于每个圆圈的中心。 Place the blue circles on a white screen which will be acting as parent to ImageView and set the attribute 将蓝色圆圈放在将充当ImageView父级的白色屏幕上并设置属性

android:layout_centerInParent="true"

to the inside image. 到内部图像。 Only this way your UI will support multiple screens. 只有这样,您的UI才能支持多个屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM