在底部顯示操作按鈕Android類庫:BottomSheet
BottomSheet是一個會在Android ListView的底部工作區域顯示一組動作。當點擊ListView的某一個項目時會在屏幕底部向上滑出一個包含若干動作的工作區域。
This library works on android 2.1+
How to use this library
- Download this library, import to your IDE (eclipse...) as a library project.
- Using Gradle (will be available soon)
compile 'com.cocosw:bottomsheet:0.+@aar'
API
- Define actions in menu xml
<menu xmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@+id/share" android:title="@string/share" android:icon="@drawable/perm_group_messages"/> <item android:id="@+id/upload" android:title="@string/upload" android:icon="@drawable/perm_group_system_clock"/> <item android:id="@+id/call" android:title="@string/call" android:icon="@drawable/perm_group_phone_calls"/> <divider/> <item android:id="@+id/help" android:title="@string/help" android:icon="@drawable/perm_group_system_tools"/> </menu>
- Call it just like you call a dialog
new BottomSheet.Builder(this).title("title").sheet(R.menu.list).listener(new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case R.id.help: q.toast("Help me!"); break; } } }).show();
- You can also add action items in builder.
Style
- Invoke darkTheme() to show build-in dark theme
- Define your style in your application, and call bottomsheet by using new BottomSheet.Builder(this,R.style.BottomSheet_StyleDialog)....
<style name="BottomSheet.StyleDialog" parent="BottomSheet.Dialog"> <item name="android:backgroundDimAmount">0.5</item> <item name="android:windowAnimationStyle">@style/BottomSheet.Animation</item> <item name="android:textColorPrimary">#DDffffff</item> <item name="android:textColorSecondary">#8Affffff</item> <item name="android:textColorHint">#42ffffff</item> <item name="dialogBackground">@color/abc_search_url_text_normal</item> <item name="listSelector">@drawable/abc_list_selector_holo_light</item> <item name="drawSelectorOnTop">false</item> <item name="dividerColor">@color/abc_search_url_text_pressed</item> </style>
- Set bottomesheet style in your activity theme
<style name="StyleTheme" parent="Theme.AppCompat"> <item name="bottomSheetStyle">@style/BottomSheet.StyleDialog</item> </style>
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!