Android仿ios底部弹出框效果
来源:互联网 发布:2010装饰定额预算软件 编辑:程序博客网 时间:2024/05/17 07:28
准备:
public class ActionSheet { public interface OnActionSheetSelected { void onClick(int whichButton); } private ActionSheet() { } public static Dialog showSheet(final Context context, final int layoutId, final OnActionSheetSelected actionSheetSelected, final OnCancelListener cancelListener) { final Dialog dialog = new Dialog(context, R.style.ActionSheet); final LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); final LinearLayout layout = (LinearLayout) inflater.inflate(layoutId, null); final int cFullFillWidth = 10000; layout.setMinimumWidth(cFullFillWidth); final Window w = dialog.getWindow(); final WindowManager.LayoutParams lp = w.getAttributes(); lp.x = 0; final int cMakeBottom = -1000; lp.y = cMakeBottom; lp.gravity = Gravity.BOTTOM; dialog.onWindowAttributesChanged(lp); dialog.setCanceledOnTouchOutside(true); if (cancelListener != null) { dialog.setOnCancelListener(cancelListener); } dialog.setContentView(layout); dialog.show(); return dialog; }}
<style name="ActionSheet" parent="@android:style/Theme.Dialog">
应用:
private ActionSheet.OnActionSheetSelected mOnActionSheetSelected;private Dialog mActionSheet;调用showGetPhotoDialog()方法
public void onActionSheetClicked(final View view) { mOnActionSheetSelected.onClick(view.getId());}public void setOnSheetClicked(final ActionSheet.OnActionSheetSelected onActionSheetSelected) { mOnActionSheetSelected = onActionSheetSelected;}private void showGetPhotoDialog() { mActionSheet = ActionSheet.showSheet(this, R.layout.actionsheet_dialog, getOnActionSheetClicked(), null);}private ActionSheet.OnActionSheetSelected getOnActionSheetClicked() { return new ActionSheet.OnActionSheetSelected() { @Override public void onClick(final int whichButton) { switch (whichButton) { case R.id.tv_button1: break;布局:case R.id.tv_button2: break;case R.id.tv_calendar: mActionSheet.dismiss(); break; default: break; } mActionSheet.dismiss(); } };}
<?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="wrap_content" android:background="@color/clear" android:orientation="vertical" android:padding="5dp" > <TextViewandroid:id="@+id/tv_botton1"android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/actionsheet_top_selector" android:clickable="true" android:gravity="center" android:onClick="onActionSheetClicked" android:text="Button1" android:textSize="18sp" /> <TextView android:id="@+id/tv_botton2" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/actionsheet_bottom_selector" android:clickable="true" android:gravity="center" android:onClick="onActionSheetClicked" android:text="Button2" android:textColor="@color/green_title_bar" android:textSize="18sp" /> <TextView android:id="@+id/cancel" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:background="@drawable/actionsheet_single_selector" android:clickable="true" android:gravity="center" android:onClick="onActionSheetClicked" android:text="@string/cancle" android:textColor="@color/cancle_blue" android:textSize="18sp" /></LinearLayout>
0 0
- Android仿ios底部弹出框效果
- 仿IOS底部弹出效果
- Android——仿ios底部弹出选择框
- 仿QQ底部弹出效果
- Android View 仿iOS7 底部弹出框
- 仿IOS底部选项效果--底部弹出PopupWindow,背景变为半透明效果
- Android仿IOS底部弹出选择菜单ActionSheet
- [Android]仿IOS选择拍照相册底部弹出
- [demo]仿IOS底部弹框效果及Android各类对话框和弹框效果
- android FloatingActionMenuAndroid 底部弹出框效果
- android-仿iOS弹出框
- android 仿IOS弹出框
- Android仿IOS弹出框
- 底部弹出框拍照,从相册选取,取消 仿 ios
- Android仿ios风格底部弹框
- 自定义仿IOS底部弹出Dialog
- Android PopupWindow实战仿QQ底部弹出
- Android仿IOS地区弹出框选择器
- Python 安装setuptools方
- 详细全面的 SpringBoot 文件上传
- socket 流程(服务器,客户端)
- 文件的拷贝、删除、保存以及关键字替换
- caffe的python接口学习(8):caffemodel中的参数及特征的抽取
- Android仿ios底部弹出框效果
- 设计模式之桥接模式(Bridge)
- 页面动态引用JS或CSS文件
- 工具优化(3)-- MarkDown基础语法与快捷键
- 国内可用的maven仓库地址
- Android图像与动画<1>
- c++石头-剪刀-布游戏c++程序设计原理与实践第4章习题
- Android Studio的下载与开发环境的搭建
- 【转】antlr使用