Android系统。如何对另一图像添加透明图像 [英] Android. How to add transparent image over another image

查看:140
本文介绍了Android系统。如何对另一图像添加透明图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何通过surfaceView做到这一点,我想知道如果我要下去的溃败。

I know how to do this via a surfaceView and I'm wondering if I should go down that rout.

我只是想(经过短暂的延迟)来创建一个与铺设在上面不透明图像全屏图像的启动画面。我不能工作了如何在XML code完成的。

I'm simply trying to create a splashscreen that has a fullscreen image with an opaque image laid over the top (after a short delay). I can't work out how this is done in XML code.

这是我......

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>

<ImageView
android:id="@+id/lightDot"
android:src="@drawable/splashlight"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@null"
 />

<ImageView
android:id="@+id/bGround"
android:src="@drawable/splash"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
 />

所以我的'lightDot'对象是半透明的,我想在短暂的延迟之后,这个覆盖在我的bGround资源之上。

So my 'lightDot' object is semi-transparent and I want to overlay this on top of my bGround resource after a short delay.

这是我的code:

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class SplashAct extends Activity implements OnClickListener{

Button mainButton;
Button lightDot;
ImageView background;
ImageView light;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

    background = (ImageView)findViewById(R.id.bGround); 
    light = (ImageView)findViewById(R.id.lightDot); 

    background.setOnClickListener(this);
}


@Override
public void onClick(View arg0) {
    //finish();
    Intent toMainGame = new Intent(this, ActOptions.class);
    startActivity(toMainGame);
    }



}

感谢您。

推荐答案

你想要的是一个的的FrameLayout

子视图中绘制一摞,顶部最近添加的孩子。

Child views are drawn in a stack, with the most recently added child on top.

您可以用覆盖旅途中使用,其中 layout_gravity 更看中的,但听起来好像这是你所需要的。

You can get more fancy with where the overlays go using layout_gravity, but it sounds like this is all you need.

    <FrameLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >

        <ImageView
            android:id="@+id/image"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/image" >
        </ImageView>

        <ImageView
            android:id="@+id/overlay"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:src="@drawable/overlay"/>
    </FrameLayout>

这篇关于Android系统。如何对另一图像添加透明图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆