Android—TextView 背景颜色与背景图片设置
来源:互联网 发布:玩minecraft学编程 编辑:程序博客网 时间:2024/06/06 01:02
Android TextView 背景颜色与背景图片设置,android textview 控件,android textview 背景,
有三种方法:
setBackgroundResource:通过颜色资源ID设置背景色。
setBackgroundColor:通过颜色值设置背景色。
setBackgroundDrawable:通过Drawable对象设置背景色。
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"/>
0 0
- Android—TextView 背景颜色与背景图片设置
- jquery mobile设置背景图片与背景颜色
- android:设置背景图片、背景颜色透明
- android:设置背景图片、背景颜色透明
- 关于背景颜色与背景图片
- Android 调整控件位置和大小(以textView为例,并设置字体与背景颜色)
- html设置按钮背景颜色与背景图片一样,即设置按钮背景透明
- 设置UINavigation的背景图片和背景颜色
- 设置navigationBar的背景颜色 背景图片
- 设置navigationController的背景颜色和背景图片
- 设置UINavigation的背景图片和背景颜色
- 自定义TextView设置边框与背景颜色添加点击事件,点击更改随机数与背景
- android在代码中四种设置控件(以及TextView的文字颜色)背景颜色的方法
- android在代码中四种设置控件(以及TextView的文字颜色)背景颜色的方法
- Android通过selector选择器设置Button或者textview的背景颜色,字体颜色
- textarea背景图片|背景颜色
- ANDROID TEXTVIEW 设置字体颜色
- ANDROID TEXTVIEW 设置字体颜色
- Makefile一些特殊符号的定义
- [python]简单的网络爬虫
- 图片加载框架Glide解析
- 《c++ primer》第二章--变量和基本类型
- 关于(int)&a 以及VC下float存储
- Android—TextView 背景颜色与背景图片设置
- 图片加载框架Picasso解析
- 【我们都爱Paul Hegarty】斯坦福IOS8公开课个人笔记6 init
- ADF笔记
- Java深入 - Java 内存分配和回收机制
- android setTag的妙用和The key must be an application-specific resource id 异常
- Windows下Apache与PHP的安装与配置
- 表示数字
- 贝叶斯学习及共轭先验