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背景颜色与背景图片设置的更多相关文章

  1. Pyqt 设置 背景颜色和背景图片、 QPalette 调色板 与QPainter 画板区别 、 不规则图片

    设置 背景颜色和背景图片 首先设置autoFillBackground属性为真然后定义一个QPalette对象设置QPalette对象的背景属性(颜色或图片)最后设置QWidget对象的Palette ...

  2. css背景颜色、背景图片,以及列表的多种样式

    背景样式 • background-color 设置元素的背景颜色.• background-image 把图像设置为背景.• background-position 设置背景图像的起始位置.• ba ...

  3. Swift自定义UINavigationController(背景颜色、背景图片、返回按钮设置、字体大小等)

    1.0  自定义UINavigationController时,背景图片.颜色等只需要设置一次,所以我们可以重写  initializa  这个方法来实现我们想要的效果 override  class ...

  4. iOS 8 设置导航栏的背景颜色和背景图片

    假设是storyboard 直接embed一个导航栏.然后在新出现的导航栏 选属性 选一下颜色就能够了 代码实现背景颜色改动:self.navigationController.navigationB ...

  5. CSS背景颜色、背景图片、平铺、定位、固定

    CSS背景颜色设置 background-color:red;如设置背景颜色为红色: 背景颜色设置支持3种写法: 颜色名 16进制 rgb CSS背景图片颜色设置 background-image:u ...

  6. Java 给 PowerPoint 文档添加背景颜色和背景图片

    在制作Powerpoint文档时,背景是非常重要的,统一的背景能让Powerpoint 演示文稿看起来更加干净美观.本文将详细讲述如何在Java应用程序中使用免费的Free Spire.Present ...

  7. 【转】Android中设置TextView的颜色setTextColor--代码中设置字体颜色

    原文网址:http://www.cnblogs.com/myphoebe/archive/2012/01/06/2314728.html android中设置TextView的颜色有方法setText ...

  8. Android TextView文字透明度和背景透明度设置

    textview1.setTextColor(Color.argb(255, 0, 255, 0)); //文字透明度 控件设为半透明: 控件名.getBackground().setAlpha(in ...

  9. Android TextView中文字通过SpannableString来设置超链接、颜色、字体等属性

    在Android中,TextView是我们最常用的用来显示文本的控件. 一般情况下,TextView中的文本都是一个样式.那么如何对于TextView中各个部分的文本来设置字体,大小,颜色,样式,以及 ...

随机推荐

  1. Linux动态库的编译与使用

    转载: http://hi.baidu.com/linuxlife/blog/item/0d3e302ae2384d3a5343c1b1.html Linux下的动态库以.so为后缀,我也是初次在Li ...

  2. C primer plus 读书笔记第八章

    本章的标题是字符输入/输出和输入确认.主要内容是讨论用于I/O的标准函数. 1.getchar()和putchar() 这两个函数之前用过,我们通过这两个函数来讨论下缓冲区. #include &qu ...

  3. Appcelerator Titanium 3.x Win7 64位平台安装步骤

    刚接触Android移动开发,第一次下载Titanium,第一次下载ADT,第一次看Javascript代码,N多第一次...... 慢慢摸索了一个礼拜把移动开发的工具链的配置学习了一下,抛砖引玉,但 ...

  4. Php面向对象 – 单例模式

    Php面向对象 – 单例模式 保证类仅仅有一个实例 1.    怎样能够解决一个类能够被无限地实例化? New,就能实例化一次,怎么去限制,用户不能无限次地new? 将构造方法私有化.全部外部的new ...

  5. Ext.Panel的主要功能

    介绍面板组件的主要配置项及经常用法,这些配置项及方法将在后面的演示样例中用到,能够把这部分内容作为兴许章节的铺垫,进行高速的浏览,Ext.Panel主要配置项目如表5-1所看到的. 表5-1  Ext ...

  6. shell 死循环

      例1: 运行脚本后会自动加载firefox浏览器,并打开指定网页.如果用户关闭firefox,脚本会再次自动重新打开firefox.     如需结束循环,中止t2.sh进程即可.注意不要同时执行 ...

  7. CentOS 7 安装教程

    参考资料: http://www.cnblogs.com/bobbylinux/articles/centos7.html

  8. jdbc连接数据库和jdbc-odbc桥接方式连接数据库

    //这种方式为jdbc直接连接,需要添加jar文件 1 package com.howe2; import java.sql.*; public class test2 { public static ...

  9. 注意在insert插入数据库时的int类型问题

    比如,一个语句,insert into mbProduct(p_UserID,p_BigID,p_qq)values("+getUserid+",'"+getdrpdl+ ...

  10. 星座物语APP

    效果图: 这里的后台管理用的是duducat,大家可以去百度看说明.图片,文字都在duducat后台服务器上,可以自己修改的.(PS:图片这里是随便找的) http://www.duducat.com ...