2010-10-29 18 views
1

我想使用来自Android可绘制资源的1x1大小的九个补丁图像。
当我试图在我的布局xml文件中使用<ImageView>来显示它时,这个永远不会显示在Android模拟器设备上。这里的xml代码如下:1x1尺寸9个补丁的图像没有显示在Android模拟器设备

<?xml version="1.0" encoding="UTF-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:padding="10px" 
> 
<RelativeLayout 
android:gravity="center_vertical" 
android:layout_width="fill_parent" 
android:layout_height="wrap_content"> 

<TextView android:id="@+id/text_label" 
    android:text="@string/text" 
    android:textSize="10pt" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

<CheckBox android:id="@+id/my_checkBox" 
    android:layout_alignBaseline="@id/text_label" 
    android:layout_alignParentRight="true" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" /> 

</RelativeLayout> 

<ImageView android:paddingTop="10px" 
     android:paddingBottom="10px" 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:src="@android:drawable/divider_horizontal_bright" /> 
</LinearLayout> 

我试过另一个相同的大小,我有同样的问题,它仍然是空白。

我对Google的研究是无关紧要的。希望你能找到我在这里做错了什么。
在此先感谢您的帮助。

Lorenth

+0

怎么样,如果你把它设置为背景?机器人:背景= “@机器人:可拉伸/ divider_horizo​​ntal_bright”。另外一项测试,如果您设置了像“#ff0000”这样的颜色,您是否会看到该行? – 2010-10-29 10:23:26

+0

9修补图像是否仍然具有1px边框以设置可扩展区域? – roundhill 2010-10-29 12:49:21

+0

@Mathias Lin。谢谢你回复我。通过将“src”更改为“背景”,它仍然是空白的。否则,通过使用预定义颜色设置背景可以很好地工作。这实际上很奇怪,因为它与“divider_horizo​​ntal_dark”现在运作良好,但与“divider_horizo​​ntal_bright”o_O不同,而它的尺寸相同。完全不明白为什么? – lorenth 2010-10-29 13:07:30

回答

1

你在为什么版本的SDK编写? 拿在divider_horizo​​ntal_bright.png文件偷看在不同版本:) 这是99%的透明8,但在4

或者,也许你的意思是像divider_horizo​​ntal_bright_opaque 50%透明的浅灰色?

+1

谢谢你回复我。我使用的是7号,这当然是关于透明度,但我认为在“明亮”和“黑暗”之间存在一些混淆。对我来说,在黑暗的背景上使用明亮的分隔线是合乎逻辑的,但事实并非如此。所以对于那些不知道在深色背景中使用“divider_horizo​​ntal_dark”而不是“divider_horizo​​ntal_bright”的人,反之亦然。感谢大家的帮助;) – lorenth 2010-11-03 09:47:05

0

这个工作对我来说:

<ImageView 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:src="@android:drawable/divider_horizontal_dark" 
    android:scaleType="fitXY" 
/>