Git Product home page Git Product logo

libbottomdialog's Introduction

libBottomDialog

一个仿IOS的底部选择器及底部弹出框警告框

renderings

![在这里插入图片描述](https://img-blog.csdnimg.cn/b46a83d7086240faacaafd5b1efdb88d.gif#pic_center =350x680)

![在这里插入图片描述](https://img-blog.csdnimg.cn/75cc779db49247909f0719861946528f.jpeg#pic_center =350x680)

Quick Setup

Add it in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			maven { url 'https://jitpack.io' }
		}
	}

Then add the dependency:

dependencies {
	        implementation 'com.github.Tobeyr1:libBottomDialog:1.0.0-alpha'
	}

Basic Usage

 BottomAlertDialog dialog = new BottomAlertDialog()
                    .openFullScreenMask(false,R.color.purple_200,0.1f)
                    .setBackGroundColor(R.color.purple_200)
                    .setCancelBtnGone()
                    .setContent("Java content")
                    .setTitle("Java title")
                    .setTitleColor(R.color.white)
                    .setGravityStyle(Gravity.BOTTOM)
                    .setPositiveButtonMethod("Ok",R.color.white,(d,view) ->{
                        d.dismiss();
                        return null;
                    })
                    .setFragmentManager(getSupportFragmentManager())
                    ;
            dialog.show();
  BottomChoiceDialog bottomChoiceDialog = new BottomChoiceDialog(
                    arrayList,(position,value) ->{
                        switch (position){
                            case 0 :
                                Toast.makeText(this, "take photo", Toast.LENGTH_SHORT).show();
                                break;
                            case 1 :
                                Toast.makeText(this, "Select from library", Toast.LENGTH_SHORT).show();
                                break;
                            case 2 :
                                Toast.makeText(this, "View image full Screen", Toast.LENGTH_SHORT).show();
                                break;
                        }
                return null;
            });
            bottomChoiceDialog.show(getSupportFragmentManager(),"dialog");

中间圆角样式

[在这里插入图片描述](https://img-blog.csdnimg.cn/558f24c6fd8848a99177e093dd1db3b7.jpeg#pic_center =350x680)

 BottomAlertDialog dialog = new BottomAlertDialog()
                    .openFullScreenMask(false, R.color.color_transparent,0.1f)
                    .setBackGroundColor(R.drawable.bg_dialog_full_radius_14_white)
                    .setContent("Exiting out of this form will remove all record information. Would you like to exit anyway?")
                    .setConfirmBg(R.drawable.bg_button_full_green_408)
                    .setCancelBg(R.drawable.bg_button_login_full_border_black_stroke_2)
                    .setTitle("Java title")
                    .setTitleColor(R.color.black)
                    .setGravityStyle(Gravity.CENTER)
                    .setCanceledOnTouchOutside(false)
                    .setWidth(getScreenWidth()-dpToPx(32))//单独设置宽度
                    //.setWindowSize(getScreenWidth()-dpToPx(32),dpToPx(280)) //整体size
                    .setPositiveButtonMethod("Ok",R.color.white,(d,view) ->{
                        d.dismiss();
                        return null;
                    })
                    .setNegativeButtonMethod("Cancel",R.color.black,(d,view) ->{
                        d.dismiss();
                        return null;
                    })
                    .setFragmentManager(getSupportFragmentManager())
                    ;
            dialog.show();
            
    private int getScreenWidth(){
        return getResources().getDisplayMetrics().widthPixels;
    }

    private int getScreenHeight(){
        return getResources().getDisplayMetrics().heightPixels;
    }

    private int dpToPx(int dp){
        return (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP,dp,getResources().getDisplayMetrics());
    }

中间圆角+弹窗阴影效果

![在这里插入图片描述](https://img-blog.csdnimg.cn/569900c89ca74aa68719bd2e892c7170.jpeg#pic_center =350x680)

 BottomAlertDialog dialog = new BottomAlertDialog()
                    .openFullScreenMask(false, R.drawable.bg_dialog_full_radius_14_white,0.1f)//同时使用圆角shape
                    .setBackGroundColor(R.drawable.bg_dialog_full_radius_14_white)
                    //.setCancelBtnGone() //是否隐藏取消按钮
                    .setContent("Exiting out of this form will remove all record information. Would you like to exit anyway?")
                    .setConfirmBg(R.drawable.bg_button_full_green_408)
                    .setCancelBg(R.drawable.bg_button_login_full_border_black_stroke_2)
                    .setTitle("Java title")
                    .setTitleColor(R.color.black)
                    .setGravityStyle(Gravity.CENTER)
                    .setCanceledOnTouchOutside(false)
                    .setWidth(getScreenWidth()-dpToPx(32))
                    //.setWindowSize(getScreenWidth()-dpToPx(32),dpToPx(280))
                    .setPositiveButtonMethod("Ok",R.color.white,(d,view) ->{
                        d.dismiss();
                        return null;
                    })
                    .setNegativeButtonMethod("Cancel",R.color.black,(d,view) ->{
                        d.dismiss();
                        return null;
                    })
                    .setFragmentManager(getSupportFragmentManager())
                    ;
            dialog.show();

bg_dialog_full_radius_14_white.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <corners android:radius="14dp" />
    <solid android:color="#FFFFFF" />
</shape>

libbottomdialog's People

Contributors

tobey-r1 avatar tobeyr1 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.