Android开关布局库:ToggleExpandLayout
jopen
9年前
一个Android开关布局库,可用在设置界面中。原先由dribbble设计。笔者说,这就是为什么他设计了这一点:
I never liked how some settings are disabled by default and not tappable until another settings has been turned on/off.
My concept is to hide these disabled settings behind their "master toggle" and then have them transition out as they become active - making the list cleaner, with less clutter and ultimately easier to use.
Preview
Usage
- XML
if yout just use one togglelayout:
<com.fenjuly.mylibrary.ToggleExpandLayout android:id="@+id/toogleLayout" android:layout_marginTop="15dp" android:layout_marginLeft="15dp" android:layout_width="match_parent" android:layout_height="match_parent" > <View android:id="@+id/view1" android:layout_width="300dp" android:layout_height="80dp" android:background="#ffffff" android:elevation="2dp" android:outlineProvider="bounds" > </View> <View android:id="@+id/rootView" android:layout_width="300dp" android:layout_height="80dp" android:background="#ffffff" android:elevation="2dp" android:outlineProvider="bounds" > </View> </com.fenjuly.mylibrary.ToggleExpandLayout>
if yout want to use more than one togglelayouts with drop and rise animation, use DropDownLayout:
<com.fenjuly.mylibrary.DropDownLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginTop="15dp" android:layout_marginLeft="15dp" > <com.fenjuly.mylibrary.ToggleExpandLayout android:id="@+id/toogleLayout" android:layout_marginTop="15dp" android:layout_marginLeft="15dp" android:layout_width="match_parent" android:layout_height="match_parent" > ... </com.fenjuly.mylibrary.ToggleExpandLayout> <com.fenjuly.mylibrary.ToggleExpandLayout android:id="@+id/toogleLayout" android:layout_marginTop="15dp" android:layout_marginLeft="15dp" android:layout_width="match_parent" android:layout_height="match_parent" > ... </com.fenjuly.mylibrary.ToggleExpandLayout> </com.fenjuly.mylibrary.DropDownLayout>
- JAVA
two methodspublic void open()andpublic void close()
layout.setOnToggleTouchListener(new ToggleExpandLayout.OnToggleTouchListener() { @Override public void onStartOpen() { } @Override public void onOpen() { } @Override public void onStartClose() { } @Override public void onClosed() { } });