微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在背景图片android上设置图片时出现问题

如何解决在背景图片android上设置图片时出现问题

| 我在我的xml中有图像视图,用于在背景图像的指定位置的背景图像上设置图像,我为一个模拟器设置了它,并且它可以工作,但是当我启动另一个不同大小的模拟器时,图像视图更改为关于背景图像,因此如何在背景图像上设置图像视图,以使imageview在任何尺寸的屏幕上都不会更改其位置 我正在提供我的代码...谢谢。 这是我的splash.xml文件,按钮和imageview更改其位置w.r.t。背景图像..用于不同尺寸的屏幕模拟器
<RelativeLayout
  xmlns:android=\"http://schemas.android.com/apk/res/android\"
  android:layout_width=\"fill_parent\"
  android:layout_height=\"fill_parent\" 
  android:id=\"@+id/TheSplashLayout\"
  android:layout_gravity=\"center\"
   android:background=\"@drawable/splashmodified\"
  >
    <ImageView 
        android:layout_width=\"60sp\" 
        android:layout_height=\"60sp\" 
        android:id=\"@+id/SplashImageView\"
        android:layout_gravity=\"center\" 
        android:layout_marginTop=\"120sp\"
        android:layout_marginLeft=\"55sp\"    
        />


    <Button 
         android:text=\"SUBMIT\" 
         android:id=\"@+id/submitt\"
         android:layout_width=\"wrap_content\"
         android:layout_height=\"wrap_content\" 
         android:layout_marginLeft=\"75px\"
         android:layout_marginTop=\"300px\"
        />
</RelativeLayout>
    

解决方法

        不明白这个问题,您可以考虑上传一些图片并为我们提供链接。我只能说的是,在指示任何尺寸时,必须避免使用
px
。这将使您可能不希望的视图在每台设备上看起来都不同。     ,        使用
dip
代替
px
sp
。 您的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\" 
  android:id=\"@+id/TheSplashLayout\"
  android:layout_gravity=\"center\"
   android:background=\"@drawable/splashmodified\"
  >
    <ImageView 
        android:layout_width=\"60dip\" 
        android:layout_height=\"60dip\" 
        android:id=\"@+id/SplashImageView\"

        android:layout_marginTop=\"120dip\"
        android:layout_marginLeft=\"55dip\"
        android:background=\"@drawable/a_thumb\"
        />


    <Button 
         android:text=\"SUBMIT\" 
         android:id=\"@+id/submitt\"
         android:layout_width=\"wrap_content\"
         android:layout_height=\"wrap_content\" 
         android:layout_marginLeft=\"75dip\"
         android:layout_marginTop=\"300dip\"
        />
</RelativeLayout>
谢谢 迪帕克     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。