导航:首页 > 操作系统 > android图片部分透明

android图片部分透明

发布时间:2025-01-08 07:41:31

android 能在屏幕上绘一张小图片,然后透明背景,还能操作能看到的背景桌面图标或程序。

package com.qdsx.cml;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
//import android.view.animation.AnimationUtils;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;
import android.widget.ImageView;
public class TestdonghuaActivity extends Activity {
private ImageView tweenMM;
// private Animation animation;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tweenMM =(ImageView)findViewById(R.id.imageView1);
}

//渐变
public void BtnAlphaOnClick(View view){
//this.doStartAnimation(R.anim.alpha_animation);
Animation b = new AlphaAnimation(0.1f, 1.0f);
b.setDuration(2000);
tweenMM.startAnimation(b);
}
//旋转
public void BtnrotateOnClick(View view){
//this.doStartAnimation(R.anim.rotate_animation);
Animation c = new RotateAnimation(0, 360,Animation.RELATIVE_TO_SELF,0.5f,Animation.RELATIVE_TO_SELF,0.5f);
c.setDuration(3000);
tweenMM.startAnimation(c);
}
//缩放
public void BtnScaleOnClick(View view){
//this.doStartAnimation(R.anim.scale_animation);
Animation d = new ScaleAnimation(0f, 1f, 0f, 1f, Animation.RELATIVE_TO_SELF,0.5f, Animation.RELATIVE_TO_SELF,0.5f);
d.setDuration(3000);
tweenMM.startAnimation(d);
}
//位移
public void BtnTransalteOnclick(View view){
//this.doStartAnimation(R.anim.translate_animation);
Animation a= new TranslateAnimation(0, 100, 0, 100);
a.setDuration(5000);
a.setFillAfter(true);//使图片移动后固定
tweenMM.startAnimation(a);
}

//开始动画方法
/* private void doStartAnimation(int animid){
animation = AnimationUtils.loadAnimation(this, animid);
animation.setFillAfter(true);//使图片移动后固定
tweenMM.startAnimation(animation);
}*/
}

Ⅱ android中怎么把一个图片设置透明化。

直接用一下代码可以让图片变得透明,具体效果自己看看吧:

java">
/**


*图片透明度处理

*

*@paramsourceImg

*原始图片

*@paramnumber

*透明度

*@return

*/

publicstaticBitmapsetAlpha(BitmapsourceImg,intnumber){

int[]argb=newint[sourceImg.getWidth()*sourceImg.getHeight()];

sourceImg.getPixels(argb,0,sourceImg.getWidth(),0,0,sourceImg.getWidth(),sourceImg.getHeight());

//获得图片的ARGB值

number=number*255/100;

for(inti=0;i<argb.length;i++){

argb=(number<<24)|(argb&0x00FFFFFF);

//修改最高2位的值

}

sourceImg=Bitmap.createBitmap(argb,sourceImg.getWidth(),sourceImg.getHeight(),Config.ARGB_8888);

returnsourceImg;

}

Ⅲ android 怎么给一块区域设置背景半透明

activity的背景透明,只需在只要在配置文件内activity属性配置内加上android:theme="@android:style/Theme.Translucent"就好了。
但是想要多方面的设置theme的话,就要在values里设置风格先:
加透明:
先在res/values下建colors.xml文件,写入:
<?xmlversionxmlversion="1.0"encoding="UTF-8"?>
<resources>
<colornamecolorname="transparent">#9000</color><!--透明度-->
</resources>
这个值设定了整个界面的透明度,为了看得见效果,现在设为透明度为56%(9/16)左右。
透明度可以用#9000值调,将这个值(ARGB)改变,就会有不同效果的透明度。
再在res/values/下建styles.xml,设置程序的风格
<?xmlversionxmlversion="1.0"encoding="utf-8"?>
<resources>
<stylenamestylename="Transparent">
<item name="android:windowBackground">@color/transparent</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowAnimationStyle">@+android:style/Animation.Translucent</item>
</style>
</resources>
加了@+android:style/Animation.Translucent这句的时候就会显示出此activity会有动画切换效果
最后一步,把这个styles.xml用在相应的Activity上。即在AndroidManifest.xml中的任意标签中添加 android:theme="@style/transparent"
如果要设置所有的activity都使用这个风格,就把这句标签语句添加在中。

Ⅳ Android 半透明图像叠加

用RelativeLayout布局就行
如:<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/不透明图片"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/透明图片"/>
</RelativeLayout>
就ok

Ⅳ 如何设置Android中控件的颜色透明度

Android中设置ImageView控件的图片的透明度应该调用View的api,以下为示例:
1、用android系统的透明效果
Java代码
android:background="@android:color/transparent"
例如 设置按钮
Java代码
<Button android:background="@android:color/transparent"
android:text="@+id/Button01"
android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff" />
2、用ARGB来控制
Java代码
半透明<Button android:background="#e0000000" />
透明<Button android:background="#00000000" />
3、设置alpha
Java代码
View v = findViewById(R.id.content);
v.getBackground().setAlpha(100);
说明: 0~255透明度值,0表示完全不透明,255表示完全透明。

阅读全文

与android图片部分透明相关的资料

热点内容
战雷录像在哪个文件夹 浏览:464
加密验证的门禁卡 浏览:729
java输出心 浏览:532
程序员的身体素质调查 浏览:382
python做一个登录系统怎么改界面 浏览:884
杨颖缓解压力的方法 浏览:144
约苗app在哪里改地址 浏览:818
tuxedo的加密协议 浏览:728
javapdftojpg 浏览:712
程序员软考课程 浏览:274
Android框架工程师 浏览:386
计算机编程机器人工程师招聘 浏览:683
怎么添加mite服务器 浏览:581
方舟怎么命令一只恐龙手机版 浏览:712
javaqq邮箱发送 浏览:170
cms淘宝客网站源码 浏览:932
如何连接选股服务器 浏览:30
华为丢了一个文件夹 浏览:521
我们买的绝地求生属于什么服务器 浏览:415
linux网卡配置dhcp 浏览:284