Skip to content

Commit 57d7296

Browse files
committed
Merge pull request #44 from orhanobut/oo/toolbar
outmost margin added
2 parents 72ad89d + ea28178 commit 57d7296

File tree

5 files changed

+32
-5
lines changed

5 files changed

+32
-5
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Simple, easy dialog solution for android.
2323

2424
### Gradle
2525
```groovy
26-
compile 'com.orhanobut:dialogplus:1.5@aar'
26+
compile 'com.orhanobut:dialogplus:1.6@aar'
2727
```
2828

2929
### Usage

app/src/main/java/com/orhanobut/android/dialogplussample/MainActivity.java

+1
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ private void showCompleteDialog(Holder holder, DialogPlus.Gravity gravity, BaseA
211211
.setOnItemClickListener(itemClickListener)
212212
.setOnDismissListener(dismissListener)
213213
.setOnCancelListener(cancelListener)
214+
.setOutMostMargin(0, 100, 0, 0)
214215
.create();
215216
dialog.show();
216217
}

dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java

+26
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,11 @@ public enum Gravity {
142142
*/
143143
private final int[] padding = new int[4];
144144

145+
/**
146+
* This margins are used for the outmost view.
147+
*/
148+
private final int[] outMostMargin = new int[4];
149+
145150
public enum ScreenType {
146151
HALF, FULL
147152
}
@@ -177,6 +182,7 @@ private DialogPlus(Builder builder) {
177182
}
178183

179184
System.arraycopy(builder.padding, 0, padding, 0, padding.length);
185+
System.arraycopy(builder.outMostMargin, 0, outMostMargin, 0, outMostMargin.length);
180186

181187
/**
182188
* 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) {
185191
*/
186192
decorView = (ViewGroup) activity.getWindow().getDecorView().findViewById(android.R.id.content);
187193
rootView = (ViewGroup) inflater.inflate(R.layout.base_container, null);
194+
195+
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
196+
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT
197+
);
198+
params.setMargins(outMostMargin[0], outMostMargin[1], outMostMargin[2], outMostMargin[3]);
199+
rootView.setLayoutParams(params);
200+
188201
contentContainer = (ViewGroup) rootView.findViewById(R.id.content_container);
189202
topView = rootView.findViewById(R.id.top_view);
190203
bottomView = rootView.findViewById(R.id.bottom_view);
@@ -562,6 +575,7 @@ public boolean onTouch(View v, MotionEvent event) {
562575
public static class Builder {
563576
private final int[] margin = new int[4];
564577
private final int[] padding = new int[4];
578+
private final int[] outMostMargin = new int[4];
565579

566580
private BaseAdapter adapter;
567581
private Context context;
@@ -696,6 +710,18 @@ public Builder setScreenType(ScreenType screenType) {
696710
return this;
697711
}
698712

713+
/**
714+
* Add margins to your outmost view which contains everything. As default they are 0
715+
* are applied
716+
*/
717+
public Builder setOutMostMargin(int left, int top, int right, int bottom) {
718+
this.outMostMargin[0] = left;
719+
this.outMostMargin[1] = top;
720+
this.outMostMargin[2] = right;
721+
this.outMostMargin[3] = bottom;
722+
return this;
723+
}
724+
699725
/**
700726
* Add margins to your dialog. They are set to 0 except when gravity is center. In that case basic margins
701727
* are applied

dialogplus/src/main/res/anim/fade_out_center.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
android:pivotY="50%"/>
1313

1414
<alpha
15-
android:fromAlpha="1.0"
16-
android:toAlpha="0.0"/>
15+
android:fromAlpha="1"
16+
android:toAlpha="0"/>
1717

1818
</set>

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
# org.gradle.parallel=true
1919
# VERSION_NAME=1.2-SNAPSHOT
2020
# VERSION_CODE=3
21-
VERSION_NAME=1.5
22-
VERSION_CODE=6
21+
VERSION_NAME=1.6
22+
VERSION_CODE=7
2323
GROUP=com.orhanobut
2424

2525
POM_DESCRIPTION=Android simple dialog

0 commit comments

Comments
 (0)