我有一个相对的布局,它有一个9块的背景图像。图像是一个简单的语音气泡,底部中间有一个完全居中的“箭头”。
relativeLayout已膨胀并放置在地图视图上。使用模拟器,语音气泡可以很容易地指向某个位置,并将扩展到其内容(文本、图像或两者)。但是,当我在手机上运行我的应用程序时,9-patch无法正常拉伸。语音气泡的“箭头”将向左偏移非常明显的量。
我主要测试的是NexusS,但也有三星Captivate和NexusOne。目标是sdk 7。为sdk 7+测试的模拟器。只有硬件设备似乎有这个问题。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
                android:layout_height="wrap_content"
                android:id="@+id/BubbleLayout"
                android:background="@drawable/bubble"
                android:layout_width="wrap_content"
                android:gravity="center_horizontal">
    <TextView android:layout_height="wrap_content"
              android:id="@+id/date"
              android:layout_width="wrap_content"
              android:maxWidth="196dp"></TextView>
    <TextView android:layout_below="@+id/date"
              android:layout_height="wrap_content"
              android:layout_width="wrap_content"
              android:maxWidth="196dp"
              android:id="@+id/summary"></TextView>
</RelativeLayout>

最佳答案

如果在不同密度下测试,请确保您有一个mdpi和一个hdpi版本。例如,如果您将9patch放入res/drawable/中,它将被视为mdpi资产,并在hdpi设备(nexus s)上自动放大。因为这是一个自动的过程,结果无法保证。

07-28 01:51
查看更多