Android Open Source - android_maskable_layout Main Activity






From Project

Back to project page android_maskable_layout.

License

The source code is released under:

Apache License

If you think the Android project android_maskable_layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.christophesmet.android.views;
/*from  w ww. j a  v a 2  s.  c  om*/
import com.christophesmet.android.views.maskableframelayout.MaskableFrameLayout;

import android.graphics.drawable.AnimationDrawable;
import android.graphics.drawable.Drawable;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;


public class MainActivity extends ActionBarActivity {

    private MaskableFrameLayout mMaskableFrameLayout;
    private Button mBtnAnimate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mMaskableFrameLayout = (MaskableFrameLayout) findViewById(R.id.frm_mask_animated);
        mBtnAnimate = (Button) findViewById(R.id.btn_animate);
        mBtnAnimate.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                animate();
            }
        });
    }

    private void animate() {
        Drawable drawable = mMaskableFrameLayout.getDrawableMask();
        if (drawable instanceof AnimationDrawable) {
            AnimationDrawable animDrawable = (AnimationDrawable) drawable;
            animDrawable.selectDrawable(0);
            animDrawable.stop();
            animDrawable.start();
        }
    }
}




Java Source Code List

com.christophesmet.android.views.MainActivity.java
com.christophesmet.android.views.maskableframelayout.MaskableFrameLayout.java