9片图像作为背景问题 [英] Problem with 9 patch image as background

查看:89
本文介绍了9片图像作为背景问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列表视图结构,相对布局使用 交替的背景图片为奇数/偶数元素。我试图设置 动态背景抽拉通过计算位置。它 与正常的位图精细的工作。但是,当我试图用 它打破了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>


可能的解决办法<一href="http://stackoverflow.com/questions/3904852/android-layout-broken-with-9-patch-background">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).

祝你好运。

这篇关于9片图像作为背景问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆