Skip to content

Commit

Permalink
Merge pull request #44 from orhanobut/oo/toolbar
Browse files Browse the repository at this point in the history
outmost margin added
  • Loading branch information
orhanobut committed May 22, 2015
2 parents 72ad89d + ea28178 commit 57d7296
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
26 changes: 26 additions & 0 deletions dialogplus/src/main/java/com/orhanobut/dialogplus/DialogPlus.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions dialogplus/src/main/res/anim/fade_out_center.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:pivotY="50%"/>

<alpha
android:fromAlpha="1.0"
android:toAlpha="0.0"/>
android:fromAlpha="1"
android:toAlpha="0"/>

</set>
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 57d7296

Please sign in to comment.