仿微信的开门效果

系统 1385 0
有人已经发过了,我掐头去尾精简了一下

仿微信的开门效果

仿微信的开门效果
这种效果跟图和布局有很大关系,并不难。
先看布局:
    
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

    <LinearLayout 
        android:id="@+id/layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical"
        android:background="@drawable/whatsnew_bg"
        android:gravity="center_horizontal|bottom"
        android:visibility="visible"
        >
        <Button
              android:id="@+id/btn_start"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="开始我的性生活"
              android:textSize="18sp"
              android:textColor="#FFFFFFFF"
              android:background="@drawable/button_bg"
			  android:layout_marginBottom="20dip"
              />
    </LinearLayout>
    <LinearLayout 
        android:id="@+id/animLayout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="horizontal"
        >
        <LinearLayout
            android:id="@+id/leftLayout" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            >
	        <ImageView 
	            android:layout_width="fill_parent"
	            android:layout_height="wrap_content"
	            android:src="@drawable/whatsnew_left"
	            android:layout_weight="1"
	            />
	        <ImageView 
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:src="@drawable/whatsnew_left_m"
	            />
        </LinearLayout>
        <LinearLayout 
            android:id="@+id/rightLayout" 
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:layout_weight="1"
            >
	        <ImageView 
	            android:layout_width="wrap_content"
	            android:layout_height="wrap_content"
	            android:src="@drawable/whatsnew_right_m"
	            />
	        <ImageView 
	            android:layout_width="fill_parent"
	            android:layout_height="wrap_content"
	            android:src="@drawable/whatsnew_right"
	            android:layout_weight="1"
	            />
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

  


在看代码:
    
package com.dl.app;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.Animation.AnimationListener;
import android.widget.Button;
import android.widget.LinearLayout;

public class TestOpenDoorActivity extends Activity {
	private Context context;
	private Button btn_start;
	
	private LinearLayout layout;
	private LinearLayout animLayout;
	private LinearLayout leftLayout;
	private LinearLayout rightLayout;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        this.context=this;
        initViews();
        
    }
    
    private void initViews(){
    	btn_start=(Button)findViewById(R.id.btn_start);
    	btn_start.setOnClickListener(onClickListener);
    	
    	layout = (LinearLayout) findViewById(R.id.layout);
    	animLayout = (LinearLayout) findViewById(R.id.animLayout);
		leftLayout  = (LinearLayout) findViewById(R.id.leftLayout);
		rightLayout  = (LinearLayout) findViewById(R.id.rightLayout);
		
    }
    
    View.OnClickListener onClickListener=new View.OnClickListener(){

		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			switch (v.getId()) {
			case R.id.btn_start:
				doOpenDoor();
				break;

			default:
				break;
			}
		}
    	
    };
    
    private void doOpenDoor(){
    	
    	layout.setVisibility(View.GONE);
    	animLayout.setVisibility(View.VISIBLE);
    	Animation leftOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.translate_left);
		Animation rightOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.translate_right);
		
		leftLayout.setAnimation(leftOutAnimation);
		rightLayout.setAnimation(rightOutAnimation);
		leftOutAnimation.setAnimationListener(new AnimationListener() {
			@Override
			public void onAnimationStart(Animation animation) {
			}
			@Override
			public void onAnimationRepeat(Animation animation) {
			}
			@Override
			public void onAnimationEnd(Animation animation) {
				leftLayout.setVisibility(View.GONE);
				rightLayout.setVisibility(View.GONE);
				Intent intent = new Intent(context,OtherActivity.class);
				startActivity(intent);
				finish();
				overridePendingTransition(R.anim.zoom_out_enter, R.anim.zoom_out_exit);
			}
		});
		
    }
}

  


其他见附件:

仿微信的开门效果


更多文章、技术交流、商务合作、联系博主

微信扫码或搜索:z360901061

微信扫一扫加我为好友

QQ号联系: 360901061

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描下面二维码支持博主2元、5元、10元、20元等您想捐的金额吧,狠狠点击下面给点支持吧,站长非常感激您!手机微信长按不能支付解决办法:请将微信支付二维码保存到相册,切换到微信,然后点击微信右上角扫一扫功能,选择支付二维码完成支付。

【本文对您有帮助就好】

您的支持是博主写作最大的动力,如果您喜欢我的文章,感觉我的文章对您有帮助,请用微信扫描上面二维码支持博主2元、5元、10元、自定义金额等您想捐的金额吧,站长会非常 感谢您的哦!!!

发表我的评论
最新评论 总共0条评论