Material-dialogs: Add the ability to remove default root layout margin

Created on 21 Sep 2018  路  5Comments  路  Source: afollestad/material-dialogs

I am using Material Dialogs with RecyclerView and it got super weird on top and bottom. Check below comparison between before and now.

Most of the code is really standard and my app is open source (but I still haven't pushed the changes).

<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/defaultRecycler"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/windowBackground"
    app:layoutManager="android.support.v7.widget.LinearLayoutManager" />
val materialDialog = MaterialDialog(activity)
            .customView(R.layout.recyclerview)
            .noAutoDismiss()
            .negativeButton(R.string.cancel) { it.dismiss() }
            .positiveButton(R.string.save) { dialog ->
                ...
            }

        materialDialog.getCustomView()?.findViewById<RecyclerView>(R.id.defaultRecycler)?.apply {
            this.overScrollMode = View.OVER_SCROLL_NEVER
            this.layoutManager = LinearLayoutManager(this.context)
            this.adapter = GroupAdapter<ViewHolder>().apply {
                add(dialogItemTitle)
                add(Section(listOfItems))
                add(dialogItemColorPicker)
            }
        }

        materialDialog.show()

0.96
screenshot_20180914-205837_change detection

2.0
screenshot_20180921-154421_change detection

improvement

All 5 comments

That 12dp of space is added by DialogLayout intentionally. It's 16dp when there is a title view, 12dp otherwise.

Looks like there may need to be an option to remove it.

Looks like there may need to be an option to remove it.

Thanks! I am completely favourable to this idea.

That was fast. Really fast. Thanks a lot!!

I just tested. Everything is great again! Thanks!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

CHOIMINSEOK picture CHOIMINSEOK  路  8Comments

arpanbag001 picture arpanbag001  路  4Comments

eygraber picture eygraber  路  3Comments

bahmandamia6982 picture bahmandamia6982  路  6Comments

enricocid picture enricocid  路  4Comments