Android Studio 在手机上匹配父图像视图周围的填充或边距
我有一个简单的 ImageView ,它具有layout_width =“match_parent”。看起来很好,Android Studio 中的 ImageView 周围没有边距或填充,但是当我用手机运行和测试它时,ImageView 周围出现了不需要的边距或填充。我搜索了类似的线程但没有帮助。我还尝试了比例类型、背景颜色和负填充。这些也不起作用。
此问题也出现在所有布局类型上。
<?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>
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 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在可绘制对象(@drawable/hthtt)中设置背景颜色(或其他更改)....共享可绘制对象代码
you need to set the background color(or other changes) in your drawable (@drawable/hthtt)....share drawable code