较大设备中的图像尺寸

发布于 2024-12-22 16:59:28 字数 646 浏览 2 评论 0原文

我的应用程序中有此图像,当我在 Droid X 和 Droid Bionic 以及其他较小的设备中测试它时,它看起来不错。但当我在 Android 平板电脑上测试它时,图像被拉伸了。我只是想知道是否有适当的方法来解决这个问题。

注意:我尝试添加图像的实际大小,例如 200dp x 300dp。但它仍然不起作用

这是我的代码

<RelativeLayout 
         android:id="@+id/image"
         android:layout_alignParentTop="true"
         android:orientation="vertical" 
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">

    <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@drawable/kittens"/>        

    </RelativeLayout>

I have this image in my app, when I tested it in my Droid X and Droid bionic and other smaller devices, it looks fine. But when I tested it on my Android Tablet, the image was stretched. I just want to know if there is a proper way to solve this issue.

Note: I have tried adding the actual size of the image like 200dp by 300 dp. But it still don't work

Here is my code

<RelativeLayout 
         android:id="@+id/image"
         android:layout_alignParentTop="true"
         android:orientation="vertical" 
         android:layout_width="wrap_content"
         android:layout_height="wrap_content">

    <ImageView
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:background="@drawable/kittens"/>        

    </RelativeLayout>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凹づ凸ル 2024-12-29 16:59:28

不要将wrap_content用于ImageView,而是使用dp,例如:

<ImageView
         android:layout_width="200dp"
         android:layout_height="200dp"
         android:background="@drawable/kittens"/>  

don't use wrap_content for ImageView, instead use dp like:

<ImageView
         android:layout_width="200dp"
         android:layout_height="200dp"
         android:background="@drawable/kittens"/>  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文