• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号
您的位置:首页 > 程序设计 >Android > Android仿ios底部弹出框效果,android仿ios底部

Android仿ios底部弹出框效果,android仿ios底部

作者:网友 字体:[增加 减小] 来源:互联网 时间:2017-05-26

网友通过本文主要向大家介绍了android 仿ios对话框,android 仿ios弹框,android wear ios版,android 仿ios滚轮,android和ios前景等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com

Android仿ios底部弹出框效果,android仿ios底部


准备:

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" >

<TextView
android:id="@+id/tv_button1"
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="按钮1"
android:textSize="18sp" />

<TextView
android:id="@+id/tv_button2"
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="按钮2"
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>

分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Android仿ios底部弹出框效果,android仿ios底部

相关文章

  • 2017-05-26Android versionCode和versionName的区别,androidversioncode
  • 2017-05-26android 5.0后对于apk 跑32 64 的逻辑
  • 2017-05-26【Android】常见问题解答,android
  • 2017-05-26Atitit.android播放smb&#160;网络邻居视频文件解决方案,atitit.androidsmb
  • 2017-05-26Android关于Dex拆分(MultiDex)技术的解析
  • 2017-05-26安卓003快速入门
  • 2017-05-26Android中TextView设置最大长度,超出显示省略号,androidtextview
  • 2017-05-26Android属性动画
  • 2017-05-26Fragment 重叠 遮盖问题,fragment遮盖
  • 2017-05-224.4.1 ContentProvider初探

文章分类

  • JavaScript
  • ASP.NET
  • PHP
  • 正则表达式
  • AJAX
  • JSP
  • ASP
  • Flex
  • XML
  • 编程技巧
  • Android
  • swift
  • C#教程
  • vb
  • vb.net
  • C语言
  • Java
  • Delphi
  • 易语言
  • vc/mfc
  • 嵌入式开发
  • 游戏开发
  • ios
  • 编程问答
  • 汇编语言
  • 微信小程序
  • 数据结构
  • OpenGL
  • 架构设计
  • qt
  • 微信公众号

最近更新的内容

    • ViewPager实现滑动翻页效果,viewpager滑动翻页
    • 菜鸟新闻2--设置沉浸式状态栏,新闻2--沉浸状态栏
    • Linux下程序产生“段错误”的原因及其解决办法
    • 做了5年软件测试了,写写心得
    • 我的android学习经历4,android学习经历4
    • Android应用程序内存泄漏介绍
    • Android自定义控件(二),android自定义控件
    • Android--绑定服务调用服务的方法
    • Android SwipeRefreshLayout下拉刷新与上拉加载+滑动删除
    • Android UI相关开源项目库汇总,android开源项目

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有