Search code examples
androidkotlinandroid-imageviewinstagram-story

Implement story reply like Instagram Android


With Instagram when a user clicks on an EditText view the next scenario occurs:

  • an emoji view is displayed [Not necessary in my case]
  • story still maintains its width & height [Not being resized] [Required]
  • keyboard is opened [Required]
  • seems like view has a transparent background

For my case when I used ADJUST_RESIZE I got the view displayed properly but ImageView of story must have scaleType [fitXY or centerCrop] which has a bad UI with some images, if I did not make it with these scaleTypes ImageView will be resized and have margins beside it.

When not use ScaleTypes[fixtXY, centerCrop] while keyboard is opened:

enter image description here

while keyboard is closed:

enter image description here


Solution

  • The solution is to make ImageView with a fixed size.

    private fun makeViewFullWidth(view: View) {
            val point = Point()
            // point will be populated with screen width and height 
            activity?.windowManager?.defaultDisplay?.getSize(point)
            val param = view.layoutParams
            param.width = point.x
            param.height = point.y
            view.layoutParams = param
        }
    
    

    you can also check this article