Skip to content

Commit

Permalink
Margins and scrolling bugs fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoscgdev committed Oct 4, 2018
1 parent c438618 commit 83e12c7
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
4 changes: 3 additions & 1 deletion app/src/main/res/layout/custom_dialog_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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:paddingLeft="24dp"
android:paddingRight="24dp">

<EditText
android:id="@+id/customEditText"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import android.support.design.widget.BottomSheetBehavior;
import android.support.design.widget.BottomSheetDialog;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import static com.marcoscg.dialogsheet.Utils.dpToPx;

/**
* Created by @MarcosCGdev on 01/12/2017.
*/
Expand Down Expand Up @@ -185,8 +188,23 @@ public void show() {
messageTextView.setTextColor(Utils.getTextColorSec(backgroundColor));
}

if (!showButtons)
textContainer.setPadding(0,0,0,0);
if (!showButtons) {
int bottomPadding = 0;
int topPadding = 0;

if (messageTextView.getText() != null && !TextUtils.isEmpty(messageTextView.getText())) {
bottomPadding = dpToPx(24);

if (titleTextView.getText() == null || TextUtils.isEmpty(titleTextView.getText()))
topPadding = dpToPx(24);
}

textContainer.setPadding(0,topPadding,0, bottomPadding);
} else {
if ((titleTextView.getText() == null || TextUtils.isEmpty(titleTextView.getText()))
&& messageTextView.getText() != null && !TextUtils.isEmpty(messageTextView.getText()))
textContainer.setPadding(0,dpToPx(24),0, 0);
}

bottomSheetDialog.show();

Expand All @@ -195,7 +213,7 @@ public void show() {
configuration.screenWidthDp > 400) {
// you can go more fancy and vary the bottom sheet width depending on the screen width
// see recommendations on https://material.io/guidelines/components/bottom-sheets.html#bottom-sheets-specs
bottomSheetDialog.getWindow().setLayout(Utils.dpToPx(400), -1);
bottomSheetDialog.getWindow().setLayout(dpToPx(400), -1);
}
}

Expand Down
28 changes: 13 additions & 15 deletions dialogsheet/src/main/res/layout/layout_bottomdialog_content.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,21 @@
android:id="@+id/mainDialogContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffff"
android:paddingTop="24dp"
android:paddingLeft="24dp"
android:paddingStart="24dp"
android:paddingRight="0dp"
android:paddingEnd="0dp">
android:background="#ffffff">

<RelativeLayout
android:id="@+id/textContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="80dp"
android:paddingLeft="0dp"
android:paddingStart="0dp"
android:paddingRight="24dp"
android:paddingEnd="24dp">
android:paddingBottom="80dp">

<ImageView
android:id="@+id/dialogIcon"
android:layout_width="56dp"
android:layout_height="56dp"
android:layout_marginRight="24dp"
android:layout_marginEnd="24dp"
android:layout_marginTop="24dp"
android:layout_marginLeft="24dp"
android:layout_marginStart="24dp"
android:scaleType="centerCrop"
android:visibility="gone"/>

Expand All @@ -41,6 +33,9 @@
android:id="@+id/dialogTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="24dp"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:singleLine="true"
android:textColor="#000000"
android:ellipsize="end"
Expand All @@ -49,10 +44,11 @@
android:layout_marginBottom="8dp"
android:visibility="gone"/>

<ScrollView
<android.support.v4.widget.NestedScrollView
android:id="@+id/scrollMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:scrollbarThumbVertical="@android:color/darker_gray"
android:scrollbarSize="4dp">

Expand All @@ -66,14 +62,16 @@
android:id="@+id/dialogMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="24dp"
android:layout_marginRight="24dp"
android:textColor="#757575"
style="@style/TextAppearance.AppCompat.Subhead"
tools:text="Looooooooooooooooong and loooooooong message here."
android:visibility="gone"/>

</LinearLayout>

</ScrollView>
</android.support.v4.widget.NestedScrollView>

</LinearLayout>

Expand Down

0 comments on commit 83e12c7

Please sign in to comment.