android switch button 报 java.lang.NullPointerException: Attempt to invoke virtual method 'boole
16lz
2021-01-23
在使用switch时,在Android 5.0版本时会报空指针异常
java.lang.NullPointerException:
Attempt to invoke virtual method 'boolean android.graphics.drawable.Drawable.getPadding(android.graphics.Rect)' on a null object reference
这个是Android 5.0的一个bug
需要在
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@id/button_START"
android:layout_alignTop="@id/button_START"
android:textOn="开启 "
android:textOff="关闭 "
android:layout_marginLeft="10dp"
android:thumb="@drawable/********" 添加自己的资源
android:track="@drawable/*******"
/>
该空间中添加红色标注部分。
thumb属性指的是:switch上面滑动的滑块
更多相关文章
- Android 关于WebView的相关属性
- RecylcerView中的子view matchParent属性失效的问题
- 【Android】Android中 Paint 字体、粗细等属性的一些设置
- 安卓笔记:安卓控件属性大全
- android中实现指针滑动的动态效果
- android layout属性 .