Tuesday, September 13, 2011

Create Transparent Activity

Today we are goning to learn "How to create Transparent Activity ?"
we need to create two activities and a transparent style theme to acheive this.

let's start with creating simple app with default activity "first" and change
main.xml to first.xml in res/layout folder.

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class FirstActivity extends Activity 
                implements OnClickListener {
   private Button btnLoad;
    public void onCreate(Bundle savedInstanceState) {
        btnLoad=(Button) findViewById(R.id.btnload);
 public void onClick(View v) {
  Intent i = new Intent(this,SecondActivity.class);




then same way create second activity with second.xml file like this
package com.rdc;

import android.app.Activity;
import android.os.Bundle;

public class SecondActivity extends Activity {
    public void onCreate(Bundle savedInstanceState) {

and the second.xml is


now create "styles.xml" in res/values folder


and also create and color.xml file in res/values


at last make entries for activities and style theme in manifest file




now if you done all the stuff in right way you will get output like this: (after tapping the button to load transparent activity)


I'd love to hear your thoughts! 

1 comment: