我对 Android 相当陌生,我正在尝试在<selector>
标签的帮助下在 Android 中实现自定义 ToggleButton。
当我不切换按钮时,图标完全居中(图标大小 -> 32dp x 32dp )。但是在切换按钮后(图标大小 -> 24dp x 24dp ),它奇怪地跑到角落。为什么会这样?
使用布局边界,
我用于的代码
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true"
android:drawable="@drawable/ic_favo_filled"/>
<item android:state_checked="false"
android:drawable="@drawable/ic_favo_non_filled"/>