Android Studio 在手机上匹配父图像视图周围的填充或边距

发布于 2025-01-12 10:31:40 字数 989 浏览 5 评论 0原文

我有一个简单的 ImageView ,它具有layout_width =“match_parent”。看起来很好,Android Studio 中的 ImageView 周围没有边距或填充,但是当我用手机运行和测试它时,ImageView 周围出现了不需要的边距或填充。我搜索了类似的线程但没有帮助。我还尝试了比例类型、背景颜色和负填充。这些也不起作用。

此问题也出现在所有布局类型上。

XML 代码

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".BlankFragment">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/hthtt" />
</FrameLayout>

测试手机上出现 ImageView 周围的边距或内边距

I have a simple ImageView that has layout_width="match_parent". It looks fine there is no margin or padding around the ImageView in the Android Studio, but when I run and test it with my phone an unwanted margin or padding appears around the ImageView. I searched for similar threads but didn't help. I also tried scale types, background color, and negative paddings. These didn't work either.

This problem also appears on all the layout types.

XML codes

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout 
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".BlankFragment">

    <ImageView
        android:id="@+id/imageView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/hthtt" />
</FrameLayout>

Margin or padding around the ImageView appears on the tested phone

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

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

发布评论

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

评论(1

凉城 2025-01-19 10:31:40

您需要在可绘制对象(@drawable/hthtt)中设置背景颜色(或其他更改)....共享可绘制对象代码

you need to set the background color(or other changes) in your drawable (@drawable/hthtt)....share drawable code

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文