我已经通过代码定义了一个包含一些项的LayerDrawable,但是我不知道如何设置LayerDrawable中"imagen“拥有的每一层的可见性。这是我的代码:
公共类layerExample扩展了Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView imagen = (ImageView)findViewById(R.id.image);
Resources r = getResources();
Drawable[] capas = new Drawable[3];
capas[0] = r.getDrawable(R.drawable.icon);
capas[1] = r.getDrawable(R.drawable.icon2);
capas[2] = r.getDrawable(R.drawable.icon3);
LayerDrawable capasDrawable = new LayerDrawable(capas);
imagen.setImageDrawable(capasDrawable);发布于 2011-08-12 04:13:39
您可以调用
<drawable object>.setAlpha(int i)I:0表示完全透明,255表示完全不透明
https://stackoverflow.com/questions/5578836
复制相似问题