1. 程式人生 > >Android 斷頭臺menu

Android 斷頭臺menu

https://github.com/Yalantis/GuillotineMenu-Android

1.首先這就是 讓menu 直接轉的  所以 如果要圖示旋轉的 效果 得 要倆個view 還得在toobar 裡邊 ~~~~

2.動畫可以換換 屬性動畫xxxxx


https://github.com/zhangqifan1/Demo_ok888

duantoutai 包直接CV  然後找來圖片一個|||    一個 三    !!!!!

public class MainActivity extends AppCompatActivity {
    private static final long RIPPLE_DURATION = 250;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = findViewById(R.id.toolbar);
        FrameLayout root=findViewById(R.id.root);
        View icon=findViewById(R.id.icon);
        if (toolbar != null) {
            setSupportActionBar(toolbar);
            getSupportActionBar().setTitle(null);
        }

        View guillotineMenu = LayoutInflater.from(this).inflate(R.layout.custom_daozi, null);
        root.addView(guillotineMenu);

        new GuillotineAnimation.GuillotineBuilder(guillotineMenu, guillotineMenu.findViewById(R.id.iconchange), icon)
                .setStartDelay(RIPPLE_DURATION)
                .setActionBarViewForAnimation(toolbar)
                .setClosedOnStart(true)
                .build();
    }
}

2.XML

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/root"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#d6000000"
    android:orientation="vertical">

    <View
        android:background="#f0f"
        android:layout_width="match_parent"
        android:layout_height="?actionBarSize"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">


        <android.support.v7.widget.Toolbar
            android:id="@+id/toolbar"
            app:contentInsetStart="0dp"
            app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:layout_height="?actionBarSize"
            android:layout_width="match_parent">

            <ImageView
                android:id="@+id/icon"
                android:src="@drawable/ic_menu_90"
                android:padding="6dp"
                android:layout_height="40dp"
                android:layout_width="40dp" />

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_gravity="center"
                android:text="我是標題"
                android:textSize="22sp" />
        </android.support.v7.widget.Toolbar>

        <View
            android:background="#ffffff"
            android:layout_width="match_parent"
            android:layout_height="1dp"/>

        <ImageView
            android:src="@mipmap/ic_launcher"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:src="@mipmap/ic_launcher"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
        <ImageView
            android:src="@mipmap/ic_launcher"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

    </LinearLayout>
</FrameLayout>

自定義的

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="#f0f"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical">

    <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        app:contentInsetStart="0dp"
        android:layout_height="?actionBarSize">
        <ImageView
            android:id="@+id/iconchange"
            android:src="@drawable/ic_menu"
            android:padding="6dp"
            android:layout_width="40dp"
            android:layout_height="40dp" />
    </android.support.v7.widget.Toolbar>


    <TextView
        android:text="我就是邊邊裡出來的!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:text="我也是邊邊裡出來的!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:text="我還是邊邊裡出來的!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />
    <TextView
        android:text="我不是邊邊裡出來的!"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />



</LinearLayout>