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. 常用PHP文件操作函数

    注:文件操作函数的行为受到 php.ini 中设置的影响. 当在 Unix 平台上规定路径时,正斜杠 (/) 用作目录分隔符.而在 Windows 平台上,正斜杠 (/) 和反斜杠 (\) 均可使用. ...

  2. .NET操作Excel笔记

    如果你新建一个项目的话,首先要添加Microsoft.Office.Core 与Microsoft.Office.Interop.Exce这两个应用,然后就能很方便的操作了,示例代码(只实现了简单的读 ...

  3. 后台测试常需要的htm样式

    <form name="form" method="post" action="#"> <input type=" ...

  4. python with妙用

    class aa(): def bb(self): print("hhhh") return "hello world" def __enter__(self) ...

  5. c#后台常用知识

    生成如:2015-10-25T12:12:12格式的时间 DateTime.Now.ToString("s") 非asp.net mvc环境下对url编码 (HttpUtility ...

  6. ImportError: No module named Crypto.Cipher

    from Crypto.Cipher import AES 报错: ImportError: No module named Crypto.Cipher 解决方法: pip install pycry ...

  7. 使用GitHub和Eclipse进行javaEE开发步骤

    下载Git客户端:链接:http://pan.baidu.com/s/1jIueUEy 密码:7gef; 下载Eclipse javaee客户端:http://www.eclipse.org/down ...

  8. 【算法】CRF

    http://www.open-open.com/doc/view/7e983c0bf1594849bcd088dc212098c4 http://wenku.baidu.com/link?url=c ...

  9. DWORD类型

    INT 代表int,DWORD 代表 unsigned longint会随着机器位数的不同而发生变化,比如在16位机上为16为,在32位机上为32位,在64位机上为64位.看看最原始的定义就知道了. ...

  10. OpenCV学习:播放avi视频文件

    #if 0 //播放avi视频文件(IplImage) #include <opencv2/opencv.hpp> using namespace std; #pragma comment ...