【发布时间】:2015-08-10 22:49:30
【问题描述】:
我有一个结构如下的片段
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/tv_title"
style="?android:tileMode"
android:layout_width="match_parent"
android:layout_height="100dp"
android:minHeight="100dp"
android:layout_alignParentTop="true"
android:fontFamily="sans-serif-light"
android:textSize="25sp"
android:gravity="center"
android:textColor="@android:color/white"
android:textAlignment="center" />
<ImageView
android:id="@+id/iv_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/tv_title"
android:contentDescription="@string/image"
android:layout_gravity="center_horizontal"
android:adjustViewBounds="true"
android:cropToPadding="false"
android:scaleType="fitXY"/>
</RelativeLayout>
问题是 TextView 和 ImageView 之间出现了不需要的线。
我尝试了很多不同的位置和图像尝试,但我无法让这条线消失。
顺便说一句,所有这些都在一个扩展了 FragmentActivity 的 Activity 中。
【问题讨论】:
-
你能发张照片吗?它将帮助我诊断您所指的线路。
-
您使用的是 9 补丁吗?因为这看起来真的很像典型的
malformed 9 patch。 -
感谢@FrankN.Stein 的快速回答。我使用了 9 个补丁来生成图像。我想你是对的。有一个已知的解决方法或自动生成图像的替代方法吗?谢谢
-
我用的是普通的图形编辑器,然后用draw9patch工具检查一下。深入了解 9 个补丁规则至关重要。查找有效帮助here。显然,如果在设置 9 个补丁标记之后缩放图像,您将丢失它们,因为颜色将被混合(用于抗锯齿)。
-
太好了,谢谢,解决方案是使用图形工具进行编辑并使用 draw9patch 进行检查。 @FrankN.Stein 请作为答案发布,我将标记为正确答案。
标签: android android-layout android-fragments imageview android-fragmentactivity