android switch无文字

浏览:48日期:2022-12-06

问题描述

switch使用了自定义drawable的thumb之后设置 textoff 和texton 文字不显示 请问是什么原因

thumb.xml

<shape xmlns:android='http://schemas.android.com/apk/res/android' android:shape='rectangle'><corners android:radius='40dp'/><solid android:color='@color/g9'/><stroke android: android:color='@color/g6'/><size android: android: /> </shape>

track的设置:android:track='@android:color/transparent'

整个switch

<Switch android: android:layout_width='match_parent' android:layout_height='match_parent' android:textOff='@string/add_device_by_pic' android:textOn='@string/add_device_by_num' android:textColor='@color/g1' android:textSize='14dp' android:thumb='@drawable/thumb' android:track='@android:color/transparent'/>

代码已添加 ,谢谢!~

问题解答

回答1:

添加属性android:showText='true'

相关文章: