Aidan Follestad 10 лет назад
Родитель
Сommit
966318b842

+ 3 - 13
library/src/main/java/com/afollestad/materialdialogs/MaterialDialog.java

@@ -19,7 +19,6 @@ import android.view.ContextThemeWrapper;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.ViewGroup;
 import android.widget.CheckBox;
 import android.widget.LinearLayout;
 import android.widget.RadioButton;
@@ -112,17 +111,6 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         if (customView != null) {
             title = (TextView) view.findViewById(R.id.titleCustomView);
             invalidateCustomViewAssociations();
-            View firstChild = customView;
-            View lastChild = customView;
-            final int frameMargin = (int) mContext.getResources().getDimension(R.dimen.dialog_frame_margin);
-            if (customView instanceof ViewGroup) {
-                ViewGroup group = (ViewGroup) customView;
-                firstChild = group.getChildAt(0);
-                lastChild = group.getChildAt(group.getChildCount() - 1);
-            }
-            if (builder.title == null || builder.title.toString().trim().isEmpty())
-                setMargin(firstChild, frameMargin, -1, -1, -1);
-            setMargin(lastChild, -1, frameMargin, -1, -1);
             ((LinearLayout) view.findViewById(R.id.customViewFrame)).addView(customView);
         } else {
             invalidateCustomViewAssociations();
@@ -215,7 +203,9 @@ public class MaterialDialog extends DialogBase implements View.OnClickListener,
         LayoutInflater li = LayoutInflater.from(mContext);
 
         if (listCallbackSingle == null && listCallbackMulti == null) {
-            setMargin(view.findViewById(R.id.customViewFrame), -1, dialogFrameMargin, -1, -1);
+            View customFrame = view.findViewById(R.id.customViewFrame);
+            customFrame.setPadding(customFrame.getPaddingLeft(), customFrame.getPaddingTop(),
+                    customFrame.getPaddingRight(), dialogFrameMargin);
         }
 
         final int itemColor = DialogUtils.resolveColor(getContext(), R.attr.item_color);

+ 3 - 1
sample/src/main/res/layout/dialog_customview.xml

@@ -2,7 +2,9 @@
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
     android:orientation="vertical"
     android:layout_width="match_parent"
-    android:layout_height="wrap_content">
+    android:layout_height="wrap_content"
+    android:paddingTop="@dimen/dialog_frame_margin"
+    android:paddingBottom="@dimen/dialog_frame_margin">
 
     <TextView
         android:layout_width="wrap_content"