gpt4 book ai didi

android - 我的 Button 9 补丁 PNG 有什么问题

转载 作者:太空狗 更新时间:2023-10-29 13:39:20 24 4
gpt4 key购买 nike

我创建了一个 9-patch PNG 但它不起作用。在 Android SDK 工具中,一切看起来都正常。但是当我将它添加到 Button 时,我只看到粉红色的背景。文本放置(补丁中的填充)似乎没问题。我做错了什么?

     <Button 
android:id="@+id/button_settings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:text="Settings"
android:textColor="#fff"
android:background="@drawable/button_settings_idle"
/>

Android SDK 工具中的 9-patch:

The 9-patch in the Android SDK Tool

普通按钮和带有 PNG 的按钮:

A normal Button and the Button with the PNG

我项目中使用的PNG

The PNG used in my project

最佳答案

将你的背景图像画成彩虹(最好是对角渐变),然后你会看到图像的哪一部分重叠,以及可能的原因。

我的猜测:水平修剪您的图片(移除中间部分并让 9patch 完成它的工作)然后看看会发生什么。如果背景图片比实际按钮大,就会发生奇怪的事情 - 比如将“文本区域”重叠在“固定”图像部分上。

关于android - 我的 Button 9 补丁 PNG 有什么问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7714076/

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