Android TextView点击效果
在Android开发中,我们有时候需要单独的点击某一段文本,如图所示:
如上图,我们要求点击新用户注册这个TextView,为了有更好的用户体验,我们肯定要设置该TextView的点击效果。下面介绍如何实现:
1. 在res目录下,单独建立color目录,用于存放颜色点击效果的资源文件,在该目录下,新建文本点击效果的文件: selector_text_press_color.xml
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"> <item android:state_selected="true" android:color="#999999"/>
<item android:state_focused="true" android:color="#999999"/>
<item android:state_pressed="true" android:color="#999999"/>
<item android:color="#00c7c0"/>
</selector>
2. 为需要点击的文本设置textColor属性:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:padding="5dp"
android:text="马上登录"
android:clickable="true"
android:textColor="@color/selector_text_press_color"
android:textSize="25sp" />
注:
1.文本的点击效果,要设置TextView的textColor属性: android:textColor="@color/selector_text_press_color";
2.设置clickable属性为true。
效果图:
源代码下载地址(免费):http://download.csdn.net/detail/zuiwuyuan/8402029
Android TextView点击效果的更多相关文章
- Android ViewGroup点击效果(背景色)
在开发Android应用的界面时,我们必然会用到本文ViewGroup,尤其是FrameLayout,LinearLayout,RelativeLayout等ViewGroup的子类: 在一些情况下, ...
- android 按钮点击效果实现
在其他人的博客里看到其实实现按钮点击效果的方法有很多,这里提到的只是其中一个办法 图片素材(我自己用截图截的,可以自己搞) 放到mipmap目录下(studio是在这个目录下 , eclipse 直接 ...
- Android ImageView点击效果
ImageView设置点击效果需要注意两点,第一个设置android:clickable="true",第二个 <item android:drawable="@d ...
- [Android]TextView点击获取部分内容
TextView控件本身有很多属性可以进行控制,如果要获取内容只需要getText()方法就可以实现,同时也可以为TextView设置各种监听器.但是,如果想要实现点击获取TextView内部的部分内 ...
- Android Button点击效果(按钮背景变色、文字变色)
一. 说明 Android Button的使用过程中,我们会需要为Button添加点击效果,不仅仅按钮的背景色需要变化,而且有时,我们连文字的颜色都希望变化,我们可以使用StateListDrawab ...
- Android textView点击滚动(跑马灯)效果
布局文件: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:to ...
- Android TextView 跑马灯效果 - 2018年6月19日
第一步在布局中添加加粗部分代码: <TextView android:id="@+id/tv_company" android:layout_width="0dp& ...
- android 按钮点击效果实现 在studio下出现的错误
在照做上一篇随笔的时候 在studio下为了方便我在写完一个 btn_select.xml 文件后直接粘贴了三个文件到drawable下 结果问题来了 总是报这样一个错误: Resource is n ...
- Android设置常见控件点击效果
一. Imageview的点击效果——图片稍微变暗突出点击效果 public class ClickImageView extends AppCompatImageView { public Clic ...
随机推荐
- Django项目:CRM(客户关系管理系统)--11--04PerfectCRM实现King_admin注册功能03
#base_admin.py #Django admin 注册功能的形式 # sites = { # 'crm':{ # 'customers':CustomerAdmin, # 'customerf ...
- Django用户登陆以及跳转后台管理页面2
请先写好以下,再来替换文件 Django用户登陆以及跳转后台管理页面1http://www.cnblogs.com/ujq3/p/7891774.html from django.shortcuts ...
- LUOGU P3112 [USACO14DEC]后卫马克Guard Mark
题目描述 Farmer John and his herd are playing frisbee. Bessie throws the frisbee down the field, but it' ...
- leetcode 21-30 easy
21. Merge Two Sorted Lists Merge two sorted linked lists and return it as a new list. The new list s ...
- 【SDOI2017】套路总结
1 第一题是裸的反演: \[\begin{align} Ans&=\prod_{i=1}^n\prod_{j=1}^ma[(i,j)]\\ &=\prod_{d=1}^na[d]^{f ...
- 2019-8-30-win10-uwp-好看的时间选择控件
title author date CreateTime categories win10 uwp 好看的时间选择控件 lindexi 2019-08-30 08:57:20 +0800 2018-0 ...
- JavaScript--返回顶部方法:锚链接、行内式js写法、外链式、内嵌式
返回网页顶部方法 一.锚链接 simpleDemo: <!DOCTYPE html> <html lang="en"> <head> <m ...
- jquery的innerWidth 和 innerHeight的使用
innerWidth This method returns the width of the element, including left and right padding, in pixels ...
- 第二章 使用eclipse创建web项目
一.启动eclipse,点击菜单栏中的File->New->Dynamic Web Project新建一个动态网站项目 二.设置项目名称和运行服务器 三.点击next,进行下一步 四.如图 ...
- [React Native]获取网络状态
使用React Native,可以使用NetInfo API获取手机当前的各个网络状态. componentWillMount() { NetInfo.fetch().done((status)=&g ...