Android: Dynamic ImageViews with layout width, height, and margin attributes

I needed to create a dynamic gallery yesterday. I could easily create an ImageView and add it to a container. But it was hard to set layout parameters to the image. I needed it to position it correctly. Most important need was to set its width as MATCH_PARENT. It can be done by setting up a proper LayoutParams object.

Read More »


Problem with fragment findViewById

I was learning android fragments. I made a separate layout for large screens.

Now I am calling updateArticleView() from MainActivity which is actually updating the Text View inflated by the ArticleFragment. I am getting NULL by this line


But getView() works fine and I can update the text. I printed the view hierarchy and it has the element, but somehow findViewById of the activity cannot return the object.¬†Application is working. I posted the problem to stackoverflow. Let’s see someone can solve the catch.

Read More »