出于某种原因,我的scrollview(现在仅包含两个TextView)拒绝填充它的父级。用于滚动视图的XML如下:滚动视图中的文本不匹配父级高度
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
style="@style/Article"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="@+id/article_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:layout_marginTop="8dp"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="32sp" />
<TextView
android:id="@+id/article_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginLeft="32dp"
android:layout_marginRight="32dp"
android:text="TextView"
android:textSize="16sp"
android:onClick="onClick"
android:clickable="true" />
</LinearLayout>
</ScrollView>
我注意到在滚动视图文本不会覆盖.9.png @drawable/background
的部分。我已经测试了几个背景,并且无论我放置什么补丁,文本都只会在延伸的部分进行。我在这里上传了一张照片。
在这种情况下,水平补丁几乎是在150×150图像的底部。这是一个像素关闭。正如你所看到的,textview会在顶部之前切断,而底部会有1像素截止。
如果我要在.png中间制作补丁,那么截断将被均匀地分割成顶部和底部。它在水平方向上做同样的事情,但由于文本不水平滚动,所以更难以看清。
我该如何摆脱这种行为?我希望文本能够从顶部流到底部,通过.9.png。这可能吗?如果没有,我在这里看到的唯一选择是使它成为一个非常短的9patch,所以它不占用太多空间。不过,我想要一个更好的解决方案。
编辑:背景图像(9patch,不知道该补丁会虽然来过)
如果他们不这样做,它有一个1个像素宽的水平补丁底部,顶部有一个像素宽的垂直贴片。看截图。
你能提供您作为背景使用的图像? – Kai 2012-03-28 02:54:22
当然,将它添加到顶部。 – 2012-03-28 03:14:33
嗯它在N1 Android 2.3.6上的预期工作,没有任何间距描述她。它是否发生在您测试过的每一个设备上,并且您是否按照程序设计来布局布局? – Kai 2012-03-28 12:29:12