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. Flume1.5.0入门:安装、部署、及flume的案例

    转自:http://www.aboutyun.com/thread-8917-1-1.html 问题导读1.什么是flume2.flume的官方网站在哪里?3.flume有哪些术语?4.如何配置flu ...

  2. Deep Reinforcement Learning from Self-Play in Imperfect-Information Games

    Heinrich, Johannes, and David Silver. "Deep reinforcement learning from self-play in imperfect- ...

  3. 第二百九十六节,python操作redis缓存-Hash哈希类型,可以理解为字典类型

    第二百九十六节,python操作redis缓存-Hash哈希类型,可以理解为字典类型 Hash操作,redis中Hash在内存中的存储格式如下图: hset(name, key, value)name ...

  4. Eclipse/MyEclipse全屏插件

    此插件可以让Eclipse/MyEclipse的界面全屏,隐藏菜单栏和状态栏! MyEclipse 2014/2015中亲测有效! 插件下载: http://files.cnblogs.com/got ...

  5. UIView的几个枚举定义

    UIView是iOS开发最主要的视图,非常多控件都是继承它,掌握当中的几个基本枚举定义,有利益理解视图的载入和參数差别. 一.UIViewAnimationCurve UIView的基本动画变化规律 ...

  6. js 查找指定函数的内容

    function test(){  //hahahhahahhahahha }alert(test.toString());

  7. 一个窗口里包含一个iframe,点击iframe内的submit按钮,返回的视图总是显示在iframe中,我想要的效果是点击按钮后返回的视图是在浏览器窗口中...?asp.net mvc 的action中,不用js怎么实现??????????

    Content("<script type='text/javascript'>parent.location.href = '" + url + "';&l ...

  8. php跨form提交方法

    1.php curl function curlPost($url,$params) { $postData = ''; foreach($params as $k => $v) { $post ...

  9. js定义对象

    1.工厂模式 function createPerson(name,age,job){ var o = {}; o.name = name; o.age = age; o.job = job; o.s ...

  10. Unity 移动端的复制这么写

    游戏上线很久了,有些玩家慢慢就流失了,为了让刚流失的玩家再度回归所以做了召回功能!如果一个200级的玩家10天没上线且成功召回的,就会给予召回玩家丰厚的奖励! Q:那如何召回这个流失的玩家呢? A:召 ...