gpt4 book ai didi

安卓:NinePatch 和 LayerList

转载 作者:行者123 更新时间:2023-11-29 18:10:14 28 4
gpt4 key购买 nike

因此,我尝试使用图层列表将 map 图像与透明的 ninepatch Drawable 叠加。像这样:

target http://f.cl.ly/items/2b1x3c3o0w3t1z0b2o2s/Screen%20Shot%202012-06-20%20at%2010.34.18%20AM.png

但我得到的只是这个(请注意 map 图像被 ninepatch 的边缘裁剪了,尽管它应该是透明的):

problem http://f.cl.ly/items/380j3E2w452Y2D2d1K0a/Screen%20Shot%202012-06-20%20at%2010.29.45%20AM.png

这是我的图层列表代码:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<nine-patch android:src="@drawable/myninepatch" />
</item>
<item android:drawable="@drawable/detail_map"/>
</layer-list>

这是我的布局 ImageView:

    <ImageView
android:layout_width="298dp"
android:layout_height="106dp"
android:layout_gravity="center"
android:layout_marginBottom="11dp"
android:src="@drawable/detail_map_overlay" />

编辑:这是 ninepatch .png:

ninepatch http://f.cl.ly/items/0X3N0d331Q15380D093n/myninepatch.9.png

有什么想法可以实现吗?不一定使用 ninepatch,但我想根据图像的大小使其可拉伸(stretch)。或者,如果您知道如何进行内在发光,那也很好。

最佳答案

重述评论并使其更清晰以供进一步阅读

你的 9 补丁无效:

  • 顶部和左侧部分仅定义可拉伸(stretch)区域。
  • 底部和右侧,内容的位置。

对于你的例子,它会做这样的事情(基于你的但没有无用的部分):

9 patch corrected

然后将其设置为 ImageView 的背景:

<ImageView
android:layout_width="298dp"
android:layout_height="106dp"
android:layout_gravity="center"
android:layout_marginBottom="11dp"
android:src="@drawable/detail_map"
android:background="@drawable/myninepatch">
</ImageView>

像这样你可以摆脱图层列表

关于安卓:NinePatch 和 LayerList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11115799/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com