Android Studio中Switch控件有关 textOn 和 textOff 用法
•属性
textOn:控件打开时显示的文字
textOff:控件关闭时显示的文字
- showText:设置是否显示开关上的文字(API 21及以上)
•用法
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="10dp"
android:gravity="center"
android:orientation="vertical"> <Switch
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:textOn="on"
android:textOff="off"
android:showText="true"/> </LinearLayout>需要注意的是,textOn 与 textOff 必须与 android:showText="true" 一起使用才起作用。
•运行效果
•自定义Switch 控件textOn和textOff字体大小
设置 Switch 属性的 android:switchTextAppearance="" 可以达到效果;
在 app/src/res 下找到 values 文件夹,右击->New->Values Resource File,新建一个 style.xml 文件;
添加代码如下:
<?xml version="1.0" encoding="utf-8"?>
<resources> <style name = "myTextAppearance" parent="@style/TextAppearance.AppCompat.Widget.Switch">
<item name="android:textSize">20sp</item>
<item name="android:textColor">@color/teal_700</item>
</style> </resources>在上述 <Switch> 控件中添加属性 android:switchTextAppearance="@style/myTextAppearance" ;
运行效果:
Android Studio中Switch控件有关 textOn 和 textOff 用法的更多相关文章
- Android Studio中Switch控件有关 thumb 和 track 用法
•任务 •属性 android:track:底部的图片(灰->绿) android:thumb:设置 Switch 上面滑动的滑块,也就是上图中的白色圆形滑块 •switch_thumb 点击 ...
- Android线程中设置控件
在Android中经常出现多线程中设置控件的值报错的情况,今天教大家封装一个简单的类避免这样的问题,同样也调用实现也非常的方便. 自定义类: /** * Created by wade on 2016 ...
- android include中的控件调用
项目中经常会有一些布局是重用的,但是如何来更好的利用这些布局中的控件 转: http://zhidao.baidu.com/link?url=GU93U8Wu31dfp7mKEx52hMJkxjFLC ...
- Android Studio自定义组合控件
在Android的开发中,为了能够服用代码,会把有一定共有特点的控件组合在一起定义成一个自定义组合控件. 本文就详细讲述这一过程.虽然这样的View的组合有一个粒度的问题.粒度太大了无法复用,粒度太小 ...
- visual studio中验证控件的使用
1.RequiredFieldValidator:验证一个必填字段,如果这个字段没填,那么,将不能提交信息. RequiredFieldValidator控件中,主要设置三个属性: (1)ErrorM ...
- Android View中的控件和监听方法...
PS:居然三天没写博客了...今天补上...东西虽多,但是都是一些基础...代码多了一些,有人可能会这样问,粘这么多代码有毛用..其实对于一个Android的初学者来说,一个完整的代码是最容易帮助理解 ...
- Android Studio 学习 - 基本控件的使用;Intent初学
Android Studio学习第三天. 今天主要学习 1. RadioButton.CheckBox.RatingBar.SeekBar等基础控件的使用. 结合Delphi中相类似的控件,在这些基本 ...
- Android Studio中Button等控件的Text中字符串默认大写的解决方法
初学Android的时候,在Android Studio中xml里面添加一个Button.EditText等控件后,它的Text总是会显示大写,即使你输入的字符串是小写也不行,控制字符串大小写的属性是 ...
- Android 中常见控件的介绍和使用
1 TextView文本框 1.1 TextView类的结构 TextView 是用于显示字符串的组件,对于用户来说就是屏幕中一块用于显示文本的区域.TextView类的层次关系如下: java.la ...
随机推荐
- how to stop MongoDB from the command line
how to stop MongoDB from the command line stop mongod https://docs.mongodb.com/manual/tutorial/manag ...
- GitHub 500 error
GitHub 500 error 无法访问了, GitHub 挂了又! error reports Downdetector Github down? Current service status a ...
- cache-control config & http cache storage location control
cache-control config & http cache storage location control cache-control 设置 where is the storage ...
- TS & error
TS & error Function implementation is missing or not immediately following the declaration.ts ht ...
- NGK公链如何构建区块链数字经济商业帝国?
2020年对于区块链市场来说,重大的利好消息莫过于NGK公链的上线了.NGK公链其广泛的市场前景.顶尖的技术,一直备受众多大型机构以及投资者所看好.同时,NGK公链也不负众望,在上线以后,就开始落地到 ...
- 16_MySQL聚合函数的使用(重点,建议大家多动手操作)
本节所涉及的SQL语句 -- 聚合函数 SELECT AVG(sal+IFNULL(comm,0)) AS avg FROM t_emp; -- SUM SELECT SUM(sal) FROM t_ ...
- CPU使用率原理及计算方式
本文转载自CPU使用率原理及计算方式 CPU:超线程和多核 超线程(Hyper-Threading ) 超线程是Intel最早提出一项技术,最早出现在2002年的Pentium4上.单个采用超线程的C ...
- 不可不知的 JVM 预热
一.JVM 架构基础 JVM 进程启动时,ClassLoader 会将需要的所有类加载到内存,主要分为以下三步: Bootstrap Class: 核心类库,由 "Bootstrap Cla ...
- java中是否存在i+1<i?
存在! 首先我们知道int的取值范围是: -2147483648~2147483647,最高位为符号位 2147483647的二进制为:01111111 11111111 11111111 11111 ...
- Vue学习笔记-Vue.js-2.X 学习(二)===>组件化开发
===重点重点开始 ========================== (三) 组件化开发 1.创建组件构造器: Vue.extends() 2.注册组件: Vue.component() 3.使用 ...

