gpt4 book ai didi

android - 自定义 Android 复选框

转载 作者:行者123 更新时间:2023-11-29 16:23:33 25 4
gpt4 key购买 nike

我正在尝试部分更改 Android 复选框的图像。按照教程 here ,我做过以下实验:

<CheckBox
android:checked="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"/>
<CheckBox
android:checked="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:button="@android:drawable/btn_check_on"
android:background="@android:drawable/btn_check_label_background"/>
<CheckBox
android:checked="true"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:button="@drawable/cb_on"
android:background="@drawable/cb_background"/>

对于第三个复选框,我已经将图像 btn_check_on.pngbtn_check_label_background.9.png 从 Android 的 SDK 复制到项目的 res/drawable 并将它们重命名为 cb_on.pngcb_background.png。虽然我希望这三个复选框具有相同的外观,但令人惊讶的是,第三个复选框比前两个更大。谁能解释为什么?我该如何解决这个问题?

最佳答案

尝试在 cb_background.9.png 中重命名图像 cb_background.png

.9 表示图像是一个九 block 图像,它会自动重新缩放。

我认为这就是为什么第三张图片更大。

有关九补丁的更多信息:here

关于android - 自定义 Android 复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5899211/

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