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. Hibernate-使用事务

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletExcepti ...

  2. sparkR could not find function "textFile"

    Yeah, that’s probably because the head() you’re invoking there is defined for SparkR DataFrames[1] ( ...

  3. python将数据写入mysql乱码的解决办法

    1.错误为:插入乱码 报错: Python模块MySQLdb操作mysql出现2019错误:Can't initialize character set utf-8 解决: 写入数据语句为: cnn ...

  4. javaScript之function定义

    背景知识 函数定义 在javaScript中,function的定义有3种: 1.匿名定义                function(){} 2.非匿名定义                fun ...

  5. UML总结---UML中的事物和关系

    UML中的事物 名称 说明 图形 类 相同属性方法的集合 接口 类或组件提供的,可以完成特定功能的一组操作的集合 协作 合作的动作 用例 系统的一个功能 节点 代表可计算的资源 活动类 有多个线程的类 ...

  6. thinkphp 查询指定分类下的文章

    $list = $Dao->query("SELECT xp_wztj.bt,xp_wztj.time,xp_wztj.gjz,xp_wztj.wz,xp_wzfl.name FROM ...

  7. API Design Principles -- QT Project

    [the original link] One of Qt’s most reputed merits is its consistent, easy-to-learn, powerfulAPI. T ...

  8. uniqid,md5,microtime

    <?php header("content-type:text/html;charset=utf-8"); $str = uniqid(md5(microtime(true) ...

  9. 基于JS实现发送短信验证码后的倒计时功能(无视页面刷新,页面关闭不进行倒计时功能)

    <!doctype html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. NHibernate连接oracle报错

    NHibernate.Exceptions.GenericADOException:“could not execute query [ select sys_user0_.USERID as USE ...