Android 制作引导层 使用透明的activity

1 制作引导层要用到的布局 主要是利用framelayout

布局如下:
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="@drawable/main_add_service_prompt_bg" >

       
            android:id="@+id/button_main_navigate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="10dp"
            android:background="@drawable/main_navigate" />

       
            android:id="@+id/imageview_main_navigate_line_up"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/button_main_navigate"
            android:layout_alignParentLeft="true"
            android:layout_marginLeft="70dp"
            android:layout_marginTop="10dp"
            android:background="@drawable/main_navigate_line_up" />

       
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_above="@+id/imageview_main_navigate_line_up"
            android:layout_centerInParent="true"
            android:background="@drawable/main_add_service_prompt" />
   


2 这个activity 要配置成 透明的 要在清单文件里配置一下:
 
            android:name="cn.unicompay.wallet.main.HomeGuideActivity"
            android:screenOrientation="portrait"
            android:theme="@android:style/Theme.Translucent" />

activity代码如下:

package cn.unicompay.wallet.main;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import cn.unicompay.wallet.BaseActivity;
import cn.unicompay.wallet.R;

public class HomeGuideActivity extends BaseActivity {
    
    Button mainNavigate;
    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE); 
        setContentView(R.layout.activity_home_transparent);
        mainNavigate = (Button) findViewById(R.id.button_main_navigate);
        mainNavigate.setOnClickListener(new OnClickListener() {
            
            @Override
            public void onClick(View v)
            {
                finish();
            }
        });
    }
}

你可能感兴趣的:(Android)