2

I'm porting an existing android app to honeycomb and the fragments API and compatibility library. I'm using the same layout, but I'm loading it into a fragment. The background is a 9patch image, but it now only covers the top left quarter of the screen. The rest of the background is white. If I change the background to a hex color, it covers the entire screen. This has never happened before switching to fragments and the layout did not change. I'm somewhat new to Android and very new to fragments, so I'm not sure if I'm missing something. The problem appears to be related to the 9patch image, but I don't know enough about Android to say that with certainty.

My layout looks like this:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@drawable/splash_background">
4

1 回答 1

1

我发现有帮助的是重新制作 9patch 图像。它们具有由您指定为非内容区域的部分定义的填充区域。
我发现解决方案是确保在整个图像中定义内容区域,并确保为大部分图像定义可拉伸区域 - 特别是如果您的九个补丁图像与您的屏幕相比很大。
请参阅下面的 9 个补丁图像。内容区域以红色突出显示:
9补丁图像

希望这会有所帮助。

于 2011-06-22T22:39:30.720 回答