textview1.setTextColor(Color.argb(255, 0, 255, 0)); //文字透明度

控件设为半透明:

控件名.getBackground().setAlpha(int);   int 在0-255之间
package net.android.alpha;

import android.widget.TextView;
import android.os.Bundle;
import android.view.ViewGroup;
import android.app.Activity;
import android.graphics.Color;
import android.widget.LinearLayout; public class touming extends Activity { final int WRAP_CONTENT = ViewGroup.LayoutParams.WRAP_CONTENT; public void onCreate(Bundle icicle) {
super.onCreate(icicle); LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
setContentView(linearLayout); TextView textview1 = new TextView(this);
textview1.setText("全部不透明=255");
//textview1.setBackgroundColor(Color.argb(255, 0, 255, 0)); //背景透明度
textview1.setTextColor(Color.argb(255, 0, 255, 0)); //文字透明度
linearLayout.addView(textview1, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT)); TextView textview2 = new TextView(this);
textview2.setText("部分透分155");
textview2.setBackgroundColor(Color.argb(155, 0, 255, 0)); //背景透明度
textview2.setTextColor(Color.argb(155, 0, 255, 0)); //文字透明度
linearLayout.addView(textview2, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT)); TextView textview3 = new TextView(this);
textview3.setText("部分透明55");
textview3.setBackgroundColor(Color.argb(55, 0, 255, 0)); ///背景透明度
textview3.setTextColor(Color.argb(55, 0, 255, 0)); //文字透明度
linearLayout.addView(textview3, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT)); TextView textview4 = new TextView(this);
textview4.setText("全部透明0");
//textview4.setBackgroundColor(Color.argb(0, 0, 255, 0)); //背景透明度
textview4.setTextColor(Color.argb(0, 0, 255, 0)); //文字透明度
linearLayout.addView(textview4, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT)); } }

最关键部分,设置字体透明度 argb(Alpha, R, G, B)

Android TextView文字透明度和背景透明度设置的更多相关文章

  1. 如何设置TextView控件的背景透明度和字体透明度

    如何设置TextView控件的背景透明度和字体透明度 设计师给的标注都是类似这样的: 字号:26 颜色:#000000 透明度:80% 其实,程序上只要需要一个色值就OK了,那么这个色值我如何计算呢? ...

  2. 设置TextView控件的背景透明度和字体透明度

    TextView tv = (TextView) findViewById(R.id.xx); 第1种:tv.setBackgroundColor(Color.argb(255, 0, 255, 0) ...

  3. Android:TextView文字跑马灯的效果实现

    解决TextView文字显示不全的问题. 简单设置跑马灯的效果: <TextView android:id="@+id/textView" android:layout_wi ...

  4. Android TextView 文字居中

    有2种方法可以设置TextView文字居中: 一:在xml文件设置:android:gravity="center" 二:在程序中设置:m_TxtTitle.setGravity( ...

  5. Android TextView文字描边的实现!!

    Android开发:文字描边 转自:http://www.oschina.net/code/snippet_586849_37287 1. [代码][Java]代码 1 2 3 4 5 6 7 8 9 ...

  6. Android TextView文字过多时通过滚动条显示多余内容

    方法一: TextView文字过多,显示不全,怎么办?我们可以为Textview添加滚动条. <TextView android:id="@+id/bus_detail_content ...

  7. android TextView 文字垂直的设置

    <TextView android:id="@+id/tv_status" android:layout_width="wrap_content" and ...

  8. Android TextView文字横向自动滚动(跑马灯)

    TextView实现文字滚动需要以下几个要点:   1.文字长度长于可显示范围:android:singleLine="true"   2.设置可滚到,或显示样式:android: ...

  9. Android TextView文字超出一屏不能显示其它的文字 解决方案

    在android上面让TextView 过多的文字实现有滚动条,之前想简单了以为设置TextView的属性就可以实现,结果还是需要ScrollView配合使用,才能达到滚动条的效果有两种方式实现, 一 ...

随机推荐

  1. Python:基本运算、基本函数(包括复数)、Math模块、NumPy模块

    基本运算 x**2 : x^2 若x是mat矩阵,那就表示x内每个元素求平方 inf:表示正无穷 逻辑运算符:and,or,not 字典的get方法 a.get(k,d) 1 1 get相当于一条if ...

  2. 【转】淘宝技术牛p博客整理

    转自:http://blog.csdn.NET/zdp072/article/details/19574793 淘宝技术委员会是由淘宝技术部高级技术人员组成的一个组织,共分为Java分会.C/C++分 ...

  3. C语言 float、double数据在内存中的存储方式

    float在内存中占4个字节(32bit),32bit=符号位(1bit)+指数位(8bit)+底数位(23bit) 指数部分 指数位占8bit,可以表示数值的范围是0-(表示0~255一共256个数 ...

  4. VC dimension(Vapnik-Chervonenkis dimension)

    二维平面的线性分类器的VC维讨论:http://www.tuicool.com/articles/JjaMfe VC维介绍:http://blog.csdn.net/lucylove3943/arti ...

  5. e686. 显示打印窗口

    The print dialog allows the user to change the default printer settings such as the default printer, ...

  6. e655. 混合风格的文本

    This example applies a new font and background color to a part of the text. You can apply styles to ...

  7. jquery -- onchange

    触发onchange 首先页面有一个input标签,并且已绑定onchange事件,如: 1 <input type="text" onchange="consol ...

  8. 1077. Kuchiguse (20)【字符串处理】——PAT (Advanced Level) Practise

    题目信息 1077. Kuchiguse (20) 时间限制100 ms 内存限制65536 kB 代码长度限制16000 B The Japanese language is notorious f ...

  9. (转)Spring开启Annotation<context:annotation-config> 和 <context:component-scan>诠释及区别

    转自:https://www.cnblogs.com/leiOOlei/p/3713989.html <context:annotation-config> 和 <context:c ...

  10. 第三章 SqlSessionFactoryBean(MyBatis)

    SqlSessionFactoryBean 在基本的 MyBatis 中,session 工厂可以使用 SqlSessionFactoryBuilder 来创建.而在 MyBatis-Spring 中 ...