Android仿IOS底部彈出對話框
在Android開發(fā)過程中,常常會因為感覺Android自帶的Dialog的樣式很丑,項目開發(fā)過程中會影響整體效果,會使得開發(fā)過程很是憂傷....(話嘮時間結(jié)束!)
本文我將介紹一款開源的Dialog仿IOS底部彈窗效果IOS_Dialog_Library的使用。我將通過幾個簡單的示例介紹IOS_Dialog_Library.zip的使用方法。
1、IOS_Dialog_Library是開源的Dialog框架,所以首先你得下載IOS_Dialog_Library.zip包,并作為Library引入你的項目(引入過程省略)。
IOS_Dialog_Library下載地址:http://xiazai.jb51.net/201701/yuanma/iOSDialogLibrary(jb51.net).rar
2、在創(chuàng)建完項目和引用完 IOS_Dialog_Library.zip 之后,開始編寫代碼。
activity_main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context=".MainActivity" android:orientation="vertical"> <Button android:id="@+id/btn1" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="消息" /> <Button android:id="@+id/btn2" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="圖片" /> <Button android:id="@+id/btn3" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="列表Item" /> <Button android:id="@+id/btn4" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="退出 彈窗" /> <Button android:id="@+id/btn5" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="錯誤提示窗口" /> </LinearLayout>
上面主要是5個Button,即演示五種不同的IOS_Dialog_Library的使用方法。
MainActivity.java
package example.com.showdialog;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import zhangphil.iosdialog.widget.ActionSheetDialog;
import zhangphil.iosdialog.widget.AlertDialog;
/**
* package:example.com.showdialog
* name:MainActivity.java
* Write by Jimmy.li
* Date:2016/4/24 16:39
*/
public class MainActivity extends Activity implements View.OnClickListener {
private Button btn1, btn2, btn3, btn4, btn5;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initView();
}
private void initView() {
btn1 = (Button) findViewById(R.id.btn1);
btn2 = (Button) findViewById(R.id.btn2);
btn3 = (Button) findViewById(R.id.btn3);
btn4 = (Button) findViewById(R.id.btn4);
btn5 = (Button) findViewById(R.id.btn5);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn1:
new ActionSheetDialog(MainActivity.this)
.builder()
.setTitle("清空消息列表后,聊天記錄依然保留,確定要清空消息列表?")
.setCancelable(true)
.setCanceledOnTouchOutside(true)
.addSheetItem("清空消息列表", ActionSheetDialog.SheetItemColor.Red
, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
}).show();
break;
case R.id.btn2:
new ActionSheetDialog(MainActivity.this)
.builder()
.setCancelable(true)
.setCanceledOnTouchOutside(true)
.addSheetItem("發(fā)送給好友",
ActionSheetDialog.SheetItemColor.Blue,
new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
})
.addSheetItem("轉(zhuǎn)載到空間相冊",
ActionSheetDialog.SheetItemColor.Blue,
new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
})
.addSheetItem("上傳到群相冊",
ActionSheetDialog.SheetItemColor.Blue,
new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
})
.addSheetItem("保存到手機",
ActionSheetDialog.SheetItemColor.Blue,
new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
}).show();
break;
case R.id.btn3:
new ActionSheetDialog(MainActivity.this)
.builder()
.setTitle("好友列表")
.setCancelable(true)
.setCanceledOnTouchOutside(true)
.addSheetItem("刪除好友", ActionSheetDialog.SheetItemColor.Red
, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
})
.addSheetItem("增加好友", ActionSheetDialog.SheetItemColor.Blue
, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
})
.addSheetItem("備注", ActionSheetDialog.SheetItemColor.Blue
, new ActionSheetDialog.OnSheetItemClickListener() {
@Override
public void onClick(int which) {
//填寫事件
}
}).show();
break;
case R.id.btn4:
new AlertDialog(MainActivity.this)
.builder()
.setTitle("退出當(dāng)前帳號")
.setMsg("再連續(xù)登陸天,就可變身為QQ達(dá)人。退出QQ可能會使你現(xiàn)有記錄歸零,確定退出?")
.setPositiveButton("確認(rèn)退出", new View.OnClickListener() {
@Override
public void onClick(View v) {
//填寫事件
}
})
.setNegativeButton("取消", new View.OnClickListener() {
@Override
public void onClick(View v) {
//填寫事件
}
}).show();
break;
case R.id.btn5:
new AlertDialog(MainActivity.this)
.builder()
.setTitle("錯誤信息")
.setMsg("你的手機sd卡出現(xiàn)問題,建議刪除不需要的文件,否則收不到圖片和視頻等打文件")
.setPositiveButton("確定", new View.OnClickListener() {
@Override
public void onClick(View v) {
//填寫事件
}
}).show();
break;
}
}
}
java代碼主要是簡要的說明了IOS_Dialog_Library的五種不同的實現(xiàn)方法及效果??梢栽谧⑨尣糠謱扅c擊事件。
3、運行效果圖


運行效果圖1 點擊"消息"示意圖2


點擊"圖片"效果圖3 點擊"列表Item"效果圖4


點擊"退出彈窗"效果圖5 點擊"錯誤提示窗口"圖6
源碼下載地址:http://xiazai.jb51.net/201701/yuanma/AndroidshowDialog(jb51.net).rar
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- iOS開發(fā)中ViewController的頁面跳轉(zhuǎn)和彈出模態(tài)
- 解決ios模擬器不能彈出鍵盤問題的方法
- react-native 封裝選擇彈出框示例(試用ios&android)
- iOS自定義提示彈出框?qū)崿F(xiàn)類似UIAlertView的效果
- ionic在開發(fā)ios系統(tǒng)微信時鍵盤擋住輸入框的解決方法(鍵盤彈出問題)
- android底部彈出iOS7風(fēng)格對話選項框(QQ對話框)--第三方開源之IOS_Dialog_Library
- 高仿IOS的Android彈出框
- iOS仿簡書、淘寶等App的View彈出效果
- iOS中自定義彈出pickerView效果(DEMO)
- iOS仿AirPods彈出動畫
相關(guān)文章
Android startActivityForResult和setResult的區(qū)別
這篇文章主要介紹了 Android startActivityForResult和setResult的區(qū)別的相關(guān)資料,希望通過本文能幫助大家理解這部分內(nèi)容,需要的朋友可以參考下2017-08-08
android Gallery組件實現(xiàn)的iPhone圖片滑動效果實例
這篇文章主要介紹了android Gallery組件實現(xiàn)的iPhone圖片滑動效果實例,即相冊內(nèi)的圖片實現(xiàn)可左右滑動的效果,需要的朋友可以參考下2014-07-07
Android 根據(jù)EditText搜索框ListView動態(tài)顯示數(shù)據(jù)
這篇文章主要介紹了Android 根據(jù)EditText搜索框ListView動態(tài)顯示數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2016-09-09
Android 使用 Path 實現(xiàn)搜索動態(tài)加載動畫效果
這篇文章主要介紹了Android 使用 Path 實現(xiàn)搜索動態(tài)加載動畫效果,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),需要的朋友可以參考下2018-08-08
21天學(xué)習(xí)android開發(fā)教程之MediaPlayer
21天學(xué)習(xí)android開發(fā)教程之MediaPlayer,MediaPlayer可以播放音頻和視頻,操作相對簡單,感興趣的小伙伴們可以參考一下2016-02-02

