标签:
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);
标签:
原文地址:http://www.cnblogs.com/tonglingqijie/p/4692723.html