From 0a20f214e72a54924f643ece36ce87cadff299dc Mon Sep 17 00:00:00 2001 From: orhanobut Date: Thu, 21 May 2015 14:46:37 +0200 Subject: [PATCH 1/2] outmost margin added --- .../dialogplussample/MainActivity.java | 1 + .../com/orhanobut/dialogplus/DialogPlus.java | 26 +++++++++++++++++++ .../src/main/res/anim/fade_out_center.xml | 4 +-- 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/orhanobut/android/dialogplussample/MainActivity.java b/app/src/main/java/com/orhanobut/android/dialogplussample/MainActivity.java index c0adb43..1f7b4c1 100644 --- a/app/src/main/java/com/orhanobut/android/dialogplussample/MainActivity.java +++ b/app/src/main/java/com/orhanobut/android/dialogplussample/MainActivity.java @@ -211,6 +211,7 @@ private void showCompleteDialog(Holder holder, DialogPlus.Gravity gravity, BaseA .setOnItemClickListener(itemClickListener) .setOnDismissListener(dismissListener) .setOnCancelListener(cancelListener) + .setOutMostMargin(0, 100, 0, 0) .create(); dialog.show(); } diff --git a/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java b/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java index 3c593ec..549457a 100644 --- a/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java +++ b/dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java @@ -142,6 +142,11 @@ public enum Gravity { */ private final int[] padding = new int[4]; + /** + * This margins are used for the outmost view. + */ + private final int[] outMostMargin = new int[4]; + public enum ScreenType { HALF, FULL } @@ -177,6 +182,7 @@ private DialogPlus(Builder builder) { } System.arraycopy(builder.padding, 0, padding, 0, padding.length); + System.arraycopy(builder.outMostMargin, 0, outMostMargin, 0, outMostMargin.length); /** * Avoid getting directly from the decor view because by doing that we are overlapping the black soft key on @@ -185,6 +191,13 @@ private DialogPlus(Builder builder) { */ decorView = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content); rootView = (ViewGroup) inflater.inflate(R.layout.base_container, null); + + FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( + ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT + ); + params.setMargins(outMostMargin[0], outMostMargin[1], outMostMargin[2], outMostMargin[3]); + rootView.setLayoutParams(params); + contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container); topView = rootView.findViewById(R.id.top_view); bottomView = rootView.findViewById(R.id.bottom_view); @@ -562,6 +575,7 @@ public boolean onTouch(View v, MotionEvent event) { public static class Builder { private final int[] margin = new int[4]; private final int[] padding = new int[4]; + private final int[] outMostMargin = new int[4]; private BaseAdapter adapter; private Context context; @@ -696,6 +710,18 @@ public Builder setScreenType(ScreenType screenType) { return this; } + /** + * Add margins to your outmost view which contains everything. As default they are 0 + * are applied + */ + public Builder setOutMostMargin(int left, int top, int right, int bottom) { + this.outMostMargin[0] = left; + this.outMostMargin[1] = top; + this.outMostMargin[2] = right; + this.outMostMargin[3] = bottom; + return this; + } + /** * Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins * are applied diff --git a/dialogplus/src/main/res/anim/fade_out_center.xml b/dialogplus/src/main/res/anim/fade_out_center.xml index f777525..e6019fc 100644 --- a/dialogplus/src/main/res/anim/fade_out_center.xml +++ b/dialogplus/src/main/res/anim/fade_out_center.xml @@ -12,7 +12,7 @@ android:pivotY="50%"/> + android:fromAlpha="1" + android:toAlpha="0"/> \ No newline at end of file From ea281784f6c1025a6d877e4ce063e7f87b49fb50 Mon Sep 17 00:00:00 2001 From: orhanobut Date: Fri, 22 May 2015 09:55:38 +0200 Subject: [PATCH 2/2] outmost margin added --- README.md | 2 +- gradle.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0d5bbbf..65a554c 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Simple, easy dialog solution for android. ### Gradle ```groovy -compile 'com.orhanobut:dialogplus:1.5@aar' +compile 'com.orhanobut:dialogplus:1.6@aar' ``` ### Usage diff --git a/gradle.properties b/gradle.properties index b980de6..9200fb5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -18,8 +18,8 @@ # org.gradle.parallel=true # VERSION_NAME=1.2-SNAPSHOT # VERSION_CODE=3 -VERSION_NAME=1.5 -VERSION_CODE=6 +VERSION_NAME=1.6 +VERSION_CODE=7 GROUP=com.orhanobut POM_DESCRIPTION=Android simple dialog