zoukankan      html  css  js  c++  java
  • Android和设置alpha(图像)透明度

    1. 没有,没有,怎么看“相关的XML属性”一节中的ImageView.setAlpha(INT)缺少另一种方法是View.setAlpha(浮动)/android:alpha代替。然而,在仅因为API级别11后者。 
    2. 它比其他的反应更容易。 有一个XML值alpha这需要双重价值。Android:alpha="0.0"那看不见的Android:alpha="0.5"透视Android:alpha="1.0"全可见 这就是它的工作原理。 
    3. 我不知道有关XML,但你可以通过代码以下面的方式做到这一点。

    ImageView myImageView = new ImageView(this);
    myImageView.setAlpha(xxx);
    

    其中0 <范围<=255,0为透明,255表示不透明。 
    4. 也许一个有用的替代纯颜色的背景: 放的LinearLayout在ImageView的的的LinearLayout作为一个不透明的过滤器。在下面的一个小例子,有一个黑色的背景:

    <LinearLayout xmlns:android=" CodeGo.net 
    android:id="@+id/layout"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#FF000000" >
    <RelativeLayout
     android:id="@+id/relativeLayout2"
     android:layout_width="match_parent"
     android:layout_height="wrap_content" >
     <ImageView
      android:id="@+id/imageView"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/icon_stop_big" />
     <LinearLayout
      android:id="@+id/opacityFilter"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:background="#CC000000"
      android:orientation="vertical" >
     </LinearLayout>
    </RelativeLayout>
    

    改变android:在的LinearLayout之间#00000000(完全透明)和#FF000000(完全不透明)的背景属性。 
    5. 现在有一个XML的替代方案:

      <ImageView
      android:id="@+id/example"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:src="@drawable/example"
      android:alpha="0.7" />
    

    它是:android:alpha=“0.7” 用从0(透明)到1(不透明)的值。 
    6. alpha可以设置连同下列十六进制格式ARGB#或#AARRGGBB。 看 
    7. 使用此表来古老版本的Android。

    ImageView myImageView;
    myImageView = (ImageView) findViewById(R.id.img);
    AlphaAnimation alpha = new AlphaAnimation(0.5F, 0.5F);
    alpha.setDuration(0); 
    alpha.setFillAfter(true); 
    myImageView.startAnimation(alpha);
  • 相关阅读:
    ASP.NET中存取图片到数据库的示例(C#)
    解决:通过asp.net 调用FlashPrinter.exe把所有可打印的文件转换成swf文件
    vs命令提示,类生成.dll文件 .snk文件
    asp.net 为指定的图片生成缩图
    asp.net自定义错误处理页面的几种方法。
    ACCESS高效分页
    C# 读取excel数据的两个方法
    ucenter asp.net接口源码,有用户中心、站内短信接口
    存储过程中的top+变量
    测试
  • 原文地址:https://www.cnblogs.com/tonglingqijie/p/4692723.html
Copyright © 2011-2022 走看看