zsmb13 / MaterialDrawerKt

A Kotlin DSL wrapper around the mikepenz/MaterialDrawer library.
Apache License 2.0
518 stars 41 forks source link

How can I align a profile to the center without a Custom View? #51

Closed jorgevalbuena56 closed 7 years ago

zsmb13 commented 7 years ago

Can you be a bit more specific? Where are you trying to center and which part of the profile?

jorgevalbuena56 commented 7 years ago

The profile header, where the user name, email and avatar are, I would to have them all align to the center of the drawer

zsmb13 commented 7 years ago

This can be done, but you'll have to use your own custom XML layout for it (this can be set via the customViewRes property inside the accountHeader block), as the base library doesn't provide specific support for it. Should be fairly straightforward though, it looks like it just needs small tweaks to the original layout that the library uses.

jorgevalbuena56 commented 7 years ago

Do you know, by any chance, where is the XML Layout used by the original library?

zsmb13 commented 7 years ago

Yes, I've actually looked it up, it's this one.

It looks like you'd just have to realign the ImageView (@+id/material_drawer_account_header_current) and the two TextViews inside the second LinearLayout (@+id/material_drawer_account_header_text_section). Maybe that LinearLayout itself too.

jorgevalbuena56 commented 7 years ago

Excellent, I'll do that and let you know

jorgevalbuena56 commented 7 years ago

I am trying to set my new view like this:

customViewRes = R.layout.material_drawer_header

And I am getting this compile error:

image

zsmb13 commented 7 years ago

I thought you wanted to center the one selected profile that's on the very top of the header. If that's what you're trying to do, then you should use the customViewRes property a level higher:

accountHeader {
    customViewRes = R.layout.something

    profile("Jane" {}
    profile("Sally") {}
}

Or did I misunderstand, and are you actually trying to center every profile item in the profile list?

jorgevalbuena56 commented 7 years ago

ohh, ok, I was wrong, Yes, you r right, I moved the line there and now it's picking up the new xml

zsmb13 commented 7 years ago

Great, it's just a matter of XML customization from there, so I'll close this. Good luck with it.