alpha-movie icon indicating copy to clipboard operation
alpha-movie copied to clipboard

java code new AlphaMovieView

Open sam2099 opened this issue 7 years ago • 1 comments

Thank you for AlphaMovie。

How can i java code to new a AlphaMovieView ?

sam2099 avatar Sep 17 '17 16:09 sam2099

try this.

            XmlPullParser xpp  = getResources().getXml(R.xml.alpha_movie_view_xml);
            try {
                xpp.next();
                xpp.nextTag();
            } catch (Exception e) {
                e.printStackTrace();
            }
            AttributeSet attr = Xml.asAttributeSet(xpp);
            Log.i("attr count ",attr.getAttributeCount()+"");
            final AlphaMovieView alpha = new AlphaMovieView(this, attr);
            LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
            params.gravity = Gravity.CENTER;
            alpha.setLayoutParams(params);
            alpha.setOpaque(false);

            frameLayout.addView(alpha);

and xml file like this image

and my xml file likes this

<?xml version="1.0" encoding="utf-8"?>
<com.alphamovie.lib.AlphaMovieView
    xmlns:custom="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="0dp"
    android:layout_height="0dp"
    android:layout_gravity="center"
    custom:alphaColor="#00ff00"
    custom:accuracy="0.4" />

ThomasXu18 avatar Dec 11 '17 02:12 ThomasXu18