这种需求下一般会将几个 RadioButton放在一个 RadioGroup中控制。 RadioGroup继承自 LinearLayout,可以设置 RadioGroup的排列方向。...这里我先不介绍 RadioButton的属性,从名字上就可以看出来它本质也是一个 Button,但是实现了 checkable接口,继承关系如下: java.lang.Object ↳android.view.View...但是往往根据真实需求来开发的时候,需要设置 RadioButton的 background中的 selector才能实现效果。...实现微信底部Tab效果 默认的 RadioButton的样式首先需要去除 RadioButton默认是前面带有圆点的,去掉前面圆点 android:button="@null" 让 RadioButton...的文本水平居中 android:gravity="center_horizontal" 给 RadioButton设置选中和未选中的样式选择器 在 drawable文件夹下新建四个 tab图标选择器,这里粘贴首页图标的选择器
findViewById(id) 找到该组件 android:background 为组件设置一个背景图片或者背景色 android:layout_width 布局的宽度,通常不直接写数字值...TextView 文本框 TextView 继承于 View 1.1 常用属性 跑马灯效果: 识别链接效果: android:autoLink 属性用于设置 TextView 是否识别链接类型和设置可识别的链接类型...而使用 background 填入图片,则是会根据 ImageView 给定的宽度来进行 拉伸 设置缩小放大的大小 3.2 常用方法 @Override public void onClick...我们可以将 Button 的 android:background 属性设置为该 drawable 资源即可轻松实现按下 按钮时不同的按钮颜色或背景 下表列出了可以设置的属性 在 res/drawable...checked android:checked 设置或获取 RadioButton 的选中状态 如果 RadioButton 未选中,那么点击它可以让它选中,但反过来是不可以的,就是不能从选中状态到未选中状态
Button按钮用法 背景可设置 : Button按钮组件可以使用android:background属性设置按钮组件的背景颜色, 图片; 1....-- 最小宽度 : android:switchMinWidth, 设置开关的最小宽度; -- 设置空白 : android:switchPadding, 设置开关 与 文本 之间的空白; -- 文本样式...: android:switchTextAppearance, 设置文本的样式; -- 选中文本 : android:textOn, android:checked为true的时候显示的文本; --...关闭文本 : android:textOff, android:checked为false的时候显示的文本; -- 文本风格 : android:textStyle, 设置文本的风格, 可以是资源文件;...; -- 字体风格 : android:typeface, 设置开关文本的字体风格; 代码示例 : XML源码 : <?
" android:background="?...也就是说,如果你没有设置的话默认的颜色就是 colorAccent 的颜色 比如: CheckBox 和 RadioButton 的 checked 状态 colorControlHightlight...这种设置和 Button 的 android:background 所不同的是,在 Android5.0 或者更高的版本上使用 colorButtonNormal 的时候会依然保持阴影和 Ripple...APP 的主要文字颜色,比如 actionbar 文本的颜色,比如 Button 中的文本颜色,EditText 中的文本颜色,AlertDialog 中的文本颜色。...比如说先我的整个 APP 的主题是这样的 <
大家好,又见面了,我是你们的朋友全栈君。...fragment不能单独存在,必须依附在Activity上,所以在Activity跳转时,实际是跳到fragment的宿主上 代码: Activity点击跳转里 Intent intent=new Intent...android:layout_weight="1" android:background="@drawable/tab_homepage" android:button="@null" android..." android:gravity="center_horizontal" /> RadioButton android:id="@+id/radio_button2" android..."@null" android:background="@drawable/tab_shopcar" android:layout_gravity="center_vertical" android
示例一: RadioButton+ Fragment 在之前介绍的你不能错过的RadioButton实践一文中,我们详细介绍了 RadioButton的使用,在示例:实现微信底部Tab效果中,只是实现了底部导航的效果切换...android:layout_height="wrap_content" android:layout_weight="1" android:background..." android:layout_weight="1" android:background="@null" android:button...3.在 Activity中实例化各个 Fragment和 RadioButton和 RadioParent的控件,设置好监听器。...(count)设置离线缓存的界面个数。
前言 大家好,我是 Vic,今天给大家带来Android开发工程师文集-相关控件的讲解,五大布局的概述,希望你们喜欢 TextView控件 TextView控件有哪些属性: android:id->控件的...id android:layout_width->控件的宽度 android:layout_height->控件的高度 android:text->文本内容 android:textSize->文本的大小...android:textColor->文本的颜色 android:background->控件的背景,可设置颜色或图片 EditText控件 EditText控件有哪些属性: android:id->...:background: // android:hint->输入提示 android:inputType->输入的类型 设置颜色 在xml中是android:textColor 在Activity中是setTextColor...AutoCompleteTextView AutoCompleteTextView为控件自动显示输入文本时出现的提示信息。
android.graphics.drawable源码目录下的drawable有十几种,博主就不一一介绍了,只说说一些常见的用法,以及容易弄错的地方。...比如说,我在drawable-hdpi放了一张背景图片bg.png(分辨率480×800),其他目录就没放,使用分辨率480×800的手机查看该APP是没有问题的,但是现在有一台分辨率高的手机如720×...常用的状态位有: state_pressed:为true时表示按下,一般用于按钮Button,图形设置于android:background state_checked:为true时表示勾选,一般用于单选框...RadioButton、复选框CheckBox,图形设置于android:drawableLeft state_selected:为true时表示选中,一般用于单选框RadioButton、复选框CheckBox...,图形设置于android:background state_focused:为true时表示获取焦点,一般用于文本框EditText,图形设置于android:background
更多详细的细节 请参考Android样式的开发:selector篇 android:state_selected: 设置是否选中状态,true表示已选中,false表示未选中。...> shape> item> selector> 然后在TextView的xml属性中设置 android:background="@drawable/tab_menu_bg...android:textSize="16sp" /> 也可以将公共的属性,提取到style中,然后设置给TextView。...的选中状态为false,然后设置点击的 TextView的选中状态为true; 4)我们是通过点击事件来设置选中的,那么在onCreate()方法里加个触发点击事件的方法模拟点击就可以了~ txt_channel.performClick...分析 导航栏显示的图片 和 导航TAB下的横线颜色 ,可以在自定义的style中设置tabIndicatorColor来决定,如果要显示TAB,textAllCaps需要设置为false。
二.RadioButton常用主要属性介绍 (1)button属性:主要用于图标大小要求不高,间隔要求也不高的场合。 (2)background属性:主要用于能够以较大空间显示图标的场合。...注意使用 background 或者 drawableLeft时 要设置 android:button="@null" 三.RadioGroup中RadioButton使用的常见问题 1.radiogroup...中的radiobutton如何设置默认选中,可以看很早之前写的这篇文章。...RadioGroup中RadioButton默认选中问题 2.相信用过RadioGroup的同学都踩过很多坑,其中之一就是这个控件设计的不是很合理,不能设置里面的radiobutton的 排列方式(几行几列...Radiogroup内如果有多个RadioButton如何设置自动换行并且保留点击事件,这个可以看我很早之前写的一篇文章 RadioGroup 自动换行且保留点击事件 3.适用于较少类型的 radiobutton
在安卓开发中用到底部菜单栏 需要用到RadioButton这个组件 实际应用的过程中,需要对按钮进行点击,为了让用户知道是否点击可这个按钮,可以设置点击后 ,该按钮的颜色或者背景发生变化。...android:textColor="@color/color_radiobutton" android:background="@color/radio_group_selector..." 8 android:checked="true" //设置为已选中,则显示的效果为选中的字体颜色 9 android:text...:background="@color/radio_group_selector" 16 android:textColor="@color/color_radiobutton...color文件夹中创建一个xml文件 color_radiobutton 用于设置改变字体的选中点击颜色变化 即文件目录为: res/color/color_radiobutton 这个文件的代码为
:orientation="horizontal" android:id="@id/main_radio" android:background="@drawable/maintab_toolbar_bg...设置成了gone!...注意为单选按钮设置的style,其中最重要的是为其background设置了home_btn_bg.xml,也就是自定义了选中效果。...,这里取巧用RadioGroup与RadioButton的特性来处理切换,然后监听事件调用setCurrentTabByTag来切换Activity。...三、总结 在这之前如果要做这种效果我恐怕第一时间就会想到用ActivityGroup来做,主要是因为TabHost的TabWidget非常难看,用起 来也不方便。
true" 默认选中,使用这个属性那么 其他的RadioButton必须设置ID android:button="@null" 去掉按钮属性,不使用小园框,自定义一个 <?...因为他们在一个组里面.所以只能单选 2.2 RadioButton实现自定义 实现自定义还是使用 android:background属性,来制定一个选择状态的xml....来实现自定义的选中和未选中 但是前提要 设置 android:button="@null"才可以. 状态选择器XML如下 android:background="@drawable/selector_radiobutton" android:text="男1" android..." android:background="@drawable/selector_radiobutton" android:text="女1"
来实现,之所以使用 RadioGroup ,是因为它内部多个 RadioButton 的状态是互斥的,也就是只有一个是选中状态,不需要我们进行多余的处理。...在 onPageSelected(int position) 方法中修改 RadioGroup 中 RadioButton 的选中状态 RadioGroup 设置 setOnCheckedChangeListener...android:layout_weight="1" /> 重点在 RadioButton 的几个属性: android:button="@null" 隐藏...RadioButton 默认的图标 android:background="@drawable/top_r_bg" 设置背景,实际上是一个 selector android:textColor="@...drawable/top_r_text" 设置文字颜色,它也是一个 selector 对于第二个 RadioButton : android:layout_marginLeft="-1dp" 和描边宽度一样
Fragment实现的底部菜单导航,是现在很多APP都有的功能,效果就是点击菜单之后,菜单实现图标和颜色的变换 实现起来主要有两种方法,一种是Tabhost,一种是Android3.0之后的Fragment...="match_parent" android:background="#FFFFFF" android:orientation="vertical"> <FrameLayout..." android:layout_height="0.2dp" android:background="@color/bg_Gray" /> background="@color/white" android:gravity="center_vertical" android:orientation="horizontal...选择通讯录Fragment public void onFoundClicked(View view){ setSelection(2); } //选择我的
Fragment实现的底部菜单导航,是现在很多APP都有的功能,效果就是点击菜单之后,菜单实现图标和颜色的变换 实现起来主要有两种方法,一种是Tabhost,一种是Android3.0之后的Fragment...android:layout_height="match_parent" android:background="#FFFFFF" android:orientation="vertical...:layout_width="match_parent" android:layout_height="0.2dp" android:background="@color...="wrap_content" android:background="@color/white" android:gravity="center_vertical"...选择通讯录Fragment public void onFoundClicked(View view){ setSelection(2); } //选择我的
应该是好久没有写有关技术类的文章了,前天还有人在群里问我,说群主很长时间没有分享干货了,今天分享一篇Android中TextView在大段的文字内容中如何让关键字高亮变色的文章 ,希望对大家有所帮助,我终于在歪路上回归正途了...今天分享的文章大概内容是在TextView中如何使大段的文字内容中关键字变色高亮显示的,分为一个关键字高亮变色显示和多个关键字一起高亮变色显示。...我已经封装成了KeywordUtil工具类,可以直接调用,效果图如下: ?...package net.loonggg.test; import java.util.regex.Matcher; import java.util.regex.Pattern; import android.text.SpannableString...; import android.text.Spanned; import android.text.style.ForegroundColorSpan; public class KeywordUtil
:textSize=”15pt” android:background=”#ff0000″ android:layout_width=”fill_parent” android:layout_height...是否将符合指定格式的文本转换可单击的超链接形式(web、email、phone、map、all、none) android:cursorVisible设置文本框中的光标是否可见 android:drawableTop...在左侧绘制一个图像 android:editable是否可以编辑 android:ellipsize超过框长度如何处理(五个属性) android:gravity设置文本框内文本对齐方式 android...:设置文本框不够显示全部内容是否允许水平滚动 android:selectAllOnFocus:文本内容可选择,一般配置hint使用 android:single设置文本是否是单行模式 二、Button...组件ImageButton(按钮) 三、EditText组件(编辑框) 四、RadioGroup组件(单选组)RadioButton组件(单选框) 五、CheckBox组件(多选框) 六、ToggleButton
:background="#485454":设置背景颜色 android:orientation="" :设置线性布局的方向 可选值: horizontal:水平的 vertical:垂直的 android...(R.layout.activity_main); //设置布局文件 基础知识 gravity: android:gravity="center" //设置组件内部的重力方向 android...:layout_gravity="center" //设置组件在父组件的位置 weight: 用于按照权重的比值设置宽和高的比例,只能应用于线性布局 给那个属性设置权重,就给这个属性设置0dp android...="点击" > RadioGroup需要设置一个id,从而对其进行监听,每一个RadioButton都需要设置id,方便获取它的值 为RadioGroup值改变时添加一个监听器...-- 定义一个竖直方向的LinearLayout,把QQ呢称与说说的文本框设置出来 --> <LinearLayout android:layout_width="match_parent
上图中,在一个radiogroup中我们设置了3个radiobutton,然后一个作为参照 <RadioGroup android:layout_width="match_parent"...android:checked="true" android:text="选中状态 底部的红线宽--5dp" /> RadioButton android:layout_width..." android:text="没有选中,底部红线窄,大概有--3dp" android:checked="false" android:background... 代码中我们看到,1 3按钮设置了我们的selector作为背景,我们分析一下过程 1 底部阴影实现 android...的选中非选中状态对应,然后加载不同item,而每个item每部基本相同,只是留白范围不同造成选中给选中的视觉差,从而区分 扩展思考 在selector中还可以设置其他的状态--按压 获取焦点等状态,大家可以结合这些即可实现
领取专属 10元无门槛券
手把手带您无忧上云