Android TextView背景颜色与背景图片设置
Android TextView 背景颜色与背景图片设置,android textview 控件,android textview 背景,
android textview 图片,android textview 颜色,android textview 组件,android textview background 。
设置文本颜色
TextView textView = (TextView) findViewById(R.id.textview1);
// 使用实际的颜色值设置字体颜色
textView.setTextColor(android.graphics.Color.RED);
设置背景颜色
有三种方法:
setBackgroundResource:通过颜色资源ID设置背景色。
setBackgroundColor:通过颜色值设置背景色。
setBackgroundDrawable:通过Drawable对象设置背景色。
下面分别演示如何用这3个方法来设置TextView组件的背景
setBackgroundResource方法设置背景:
textView.setBackgroundResource(R.color.background); setBackgroundColor方法设置背景:
textView.setBackgroundColor(android.graphics.Color.RED); setBackgroundDrawable方法设置背景:
Resources resources=getBaseContext().getResources();
Drawable drawable=resources.getDrawable(R.color.background);
textView.setBackgroundDrawable(drawable);
设置背景图片
1、将背景图片放置在 drawable-mdpi 目录下,假设图片名为 bgimg.jpg 。
2、main.xml 文件
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/bgimg"
/>
ANDROID TEXTVIEW 背景颜色与背景图片设置
2014-06-26 16:34:51 By: dwtedx
Android TextView 背景颜色与背景图片设置,android textview 控件,android textview 背景,
android textview 图片,android textview 颜色,android textview 组件,android textview background 。
设置文本颜色
TextView textView =(TextView) findViewById(R.id.textview1);// 使用实际的颜色值设置字体颜色
textView.setTextColor(android.graphics.Color.RED);
设置背景颜色
有三种方法:
setBackgroundResource:通过颜色资源ID设置背景色。
setBackgroundColor:通过颜色值设置背景色。
setBackgroundDrawable:通过Drawable对象设置背景色。
下面分别演示如何用这3个方法来设置TextView组件的背景
setBackgroundResource方法设置背景:
以下为引用内容:
textView.setBackgroundResource(R.color.background); setBackgroundColor方法设置背景:
textView.setBackgroundColor(android.graphics.Color.RED); setBackgroundDrawable方法设置背景:Resources resources=getBaseContext().getResources();Drawable drawable=resources.getDrawable(R.color.background);
textView.setBackgroundDrawable(drawable);
设置背景图片
1、将背景图片放置在 drawable-mdpi 目录下,假设图片名为 bgimg.jpg 。
2、main.xml 文件
Android TextView背景颜色与背景图片设置的更多相关文章
- Pyqt 设置 背景颜色和背景图片、 QPalette 调色板 与QPainter 画板区别 、 不规则图片
设置 背景颜色和背景图片 首先设置autoFillBackground属性为真然后定义一个QPalette对象设置QPalette对象的背景属性(颜色或图片)最后设置QWidget对象的Palette ...
- css背景颜色、背景图片,以及列表的多种样式
背景样式 • background-color 设置元素的背景颜色.• background-image 把图像设置为背景.• background-position 设置背景图像的起始位置.• ba ...
- Swift自定义UINavigationController(背景颜色、背景图片、返回按钮设置、字体大小等)
1.0 自定义UINavigationController时,背景图片.颜色等只需要设置一次,所以我们可以重写 initializa 这个方法来实现我们想要的效果 override class ...
- iOS 8 设置导航栏的背景颜色和背景图片
假设是storyboard 直接embed一个导航栏.然后在新出现的导航栏 选属性 选一下颜色就能够了 代码实现背景颜色改动:self.navigationController.navigationB ...
- CSS背景颜色、背景图片、平铺、定位、固定
CSS背景颜色设置 background-color:red;如设置背景颜色为红色: 背景颜色设置支持3种写法: 颜色名 16进制 rgb CSS背景图片颜色设置 background-image:u ...
- Java 给 PowerPoint 文档添加背景颜色和背景图片
在制作Powerpoint文档时,背景是非常重要的,统一的背景能让Powerpoint 演示文稿看起来更加干净美观.本文将详细讲述如何在Java应用程序中使用免费的Free Spire.Present ...
- 【转】Android中设置TextView的颜色setTextColor--代码中设置字体颜色
原文网址:http://www.cnblogs.com/myphoebe/archive/2012/01/06/2314728.html android中设置TextView的颜色有方法setText ...
- Android TextView文字透明度和背景透明度设置
textview1.setTextColor(Color.argb(255, 0, 255, 0)); //文字透明度 控件设为半透明: 控件名.getBackground().setAlpha(in ...
- Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性
在Android中,TextView是我们最常用的用来显示文本的控件. 一般情况下,TextView中的文本都是一个样式.那么如何对于TextView中各个部分的文本来设置字体,大小,颜色,样式,以及 ...
随机推荐
- Retina 屏移动设备 1px解决方案
做移动端H5页面开发时都会遇到这样的问题,用 CSS 定义 1px 的实线边框,在 window.devicePixelRatio=2 的屏幕上会显示成 2px,在 window.devicePix ...
- cocos日记
n/2/2015 ADT E:\All Setup\eclipse_past\Eclipse_plugins_ADT 15/2/2015 配置cocos win32 开发环境 链接:htt ...
- soundPool和audiofocus
audiofocus试验: 使用soundPool来写一个播放音频的porject. 资源初始化: setContentView(R.layout.activity_main); Button bt1 ...
- 两台Linux机之间传送文件
最近实验室里接管了一台服务器,经常需要用到服务器与自己主机之间进行文件传输,因此,在此介绍一下两台Linux主机之间的一些操作,方便后来者. 1. Linux.Windows主机远程访问Linux服务 ...
- RHEL7查看网卡配置命令ip addr show
Validating Network Address Configuration To verify the configuration of the network address, you nee ...
- 面试题 HashMap 数据结构 实现原理
数据结构 HashMap的数据结构 数据结构中有数组和链表来实现对数据的存储,但这两者基本上是两个极端. 数组:数组存储区间是连续的,占用内存严重,故空间复杂的很大.但数组的二分查找时间复杂度小,为O ...
- OD: DEP & Ret2Libc
Data Execution Prevention,数据执行保护,专门用来弥补计算机对数据和代码混淆这一天然缺陷. DEP 的原理是将数据所在的内存页(默认的堆.各种堆栈页.内存池页)标记为不可执行, ...
- spring aop原理分析
持续更新... aop跟java代理模式有关. java.lang.reflect.Proxy java.lang.reflect.InvocationHandler 工厂模式用到java反射. ao ...
- oralce中exists not exists in not in对于NULL的处理
1. 先讨论 in 与 not in中存在NULL的情况, sql语句如下: 1 select 1 result1 from dual where 1 not in (2, 3); 2 3 4 s ...
- python的hashlib模块
# -*- coding: utf-8 -*- """python 的MD5 sha1 模块""" import hashlib #md5的 ...