android-技术教程-设置文本可见透明度
最近都没写波可,因为在疯狂得赶项目,其中有一天疯狂得写了16个小时,真得写到了手发软,脚无力,脑袋变白痴得状态,好在终于阶段性小结了一下,希望以后能不那么赶,可以有更多时间研究各种有意思得技术。
发一篇关于android设置文本透明度得例子。
package com.google.android.alphaTest;
import android.widget.TextView;
import android.os.Bundle;
import android.view.ViewGroup;
import android.app.Activity;
import android.graphics.Color;
import android.widget.LinearLayout;
/*本教程版权为http://yuefeng.iteye.com/ 博客主人所有,代码随意使用,如想转载请表明出处,这是对写教程人得起码尊重,谢谢:)
*/
public class alphaTest 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 TV1 = new TextView(this);
TV1.setText("全部不透明=255");
TV1.setBackgroundColor(Color.argb(255, 0, 255, 0));
linearLayout.addView(TV1, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT));
TextView TV2 = new TextView(this);
TV2.setText("部分透明=155");
TV2.setBackgroundColor(Color.argb(155, 0, 255, 0));
linearLayout.addView(TV2, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT));
TextView TV3 = new TextView(this);
TV3.setText("部分透明=55");
TV3.setBackgroundColor(Color.argb(55, 0, 255, 0));
linearLayout.addView(TV3, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT));
TextView TV4 = new TextView(this);
TV4.setText("全部透明=0");
TV4.setBackgroundColor(Color.argb(0, 0, 255, 0));
linearLayout.addView(TV4, new LinearLayout.LayoutParams(WRAP_CONTENT,
WRAP_CONTENT));
}
}