Show AlertDialog with ImageView without any padding

后端 未结 8 1352
灰色年华
灰色年华 2020-12-23 15:04

EDIT - SOLUTION:

I ended up figuring out a way to solve this issue. Because manually changing the height of the ImageView removes the extra padding,

相关标签:
8条回答
  • 2020-12-23 15:40

    Both your layout and image view have layout_width="match_parent". This tells the view (either the layout or the image view) to stretch itself so that it fills the parent container. Try changing this property to wrap_content. You can find detailed explanation of the property in the official documentation - here

    Setting it to wrap_content should have the same effect as on the height - it should be just wide enough to draw the content (the image in this case) instead of fixing its size (to that of the parent/container)

    0 讨论(0)
  • 2020-12-23 15:45

    The CustomPanel of an AlertDialog has a 5dp top and bottom padding. You can override these using:

    replace this line

    dialog.setView(dialogLayout);
    

    into

    dialog.setView(dialogLayout, 0, 0, 0, 0);
    

    For more information refer these links,

    Unable to get proper custom AlertDialog

    0 讨论(0)
提交回复
热议问题