8
在ImageView周围进行不必要的填充
我需要在所有活动/视图中都包含标题图形。具有标题的文件称为header.xml: <?xml version="1.0" encoding="utf-8"?> <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#0000FF" android:padding="0dip"> <ImageView xmlns:android="http://schemas.android.com/apk/res/android" android:src="@drawable/header" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="0dip" android:layout_marginTop="0dip" android:layout_marginBottom="0dip" android:padding="0dip" android:paddingTop="0dip" android:paddingBottom="0dip" android:layout_gravity="fill" android:background="#00FF00" /> </FrameLayout> 注意android:background="#00FF00"(绿色),这只是可视化目的。 我将它们包含在我的视图中,如下所示: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" style="@style/white_background"> <include layout="@layout/header" /> (...) 因此,当我实际尝试时,结果看起来像左图,而不是它应该看起来像(右): (1)这-橙色-部分是所讨论的图像/ ImageView。 (2)无用的绿色边框。注意:通常,绿色区域是透明的-因为我设置了,所以只有绿色background。 注意顶部图像周围的绿色边框;它是ImageView的一部分,我只是想不出它为什么存在或如何摆脱它。它将所有填充和边距设置为0(但省略时结果是相同的)。图片为480x64px jpeg *,我将其放在res / drawable中(drawable-Xdpi尽管不是其中之一)。 (* …