9片图像作为背景问题图像、背景、问题

2023-09-06 02:01:56 作者:梦魁

我有一个列表视图结构,相对布局使用 交替的背景图片为奇数/偶数元素。我试图设置 动态背景抽拉通过计算位置。它 与正常的位图精细的工作。但是,当我试图用 它打破了UI ninepatch图像,所有的元素失真。什么 我做错了什么?难道是如何ninepatch创建映像或 有一个不同的方式来使用一个ninepatch图像相比正常 位图。

I have a list view structure, with Relative layout that uses alternating background images for odd/even elements. I'm trying to set the background drawable dynamically by calculating the position. It worked fine with the normal bitmap. But when I tried to use the ninepatch image it breaks the UI, all the elements get distorted. What am I doing wrong? Could it be how the ninepatch image is created or is there a different way to use a ninepatch image compared to a normal bitmap.

我的列表视图XML是这样的

My List View XML goes like this

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content" android:id="@+id/id01"
       android:background="@drawable/my_9patch_bg_image">
       <ImageView  />
       <RelativeLayout>
         <ImageView  />
          <TextView  />
          <TextView  />
       </RelativeLayout>
</RelativeLayout>

可能的解决办法here可能对我的问题。这是准确的,虽然我也来试试吧。

May be the solution here might work for my problem. It's exact though I have to try it.

推荐答案

由于现在没有人回答您一年... 我有你需要setpadding零(即使你不需要它)。

Since nobody answered you for a year now... I had the same issue you need to setpadding of zero (even if you don't need it).

祝你好运。

 
精彩推荐