Setting LayoutParams programmatically not working
<p>I want Imageview width and height to match the whole screen. After using Layout Inflater to inflate view I am setting Layout params on the view.But the height of image is not covering the whole screen. Here is the code:</p>

<pre><code>    LayoutInflater mLayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View itemView = mLayoutInflater.inflate(R.layout.viewpager, container, false);
    itemView.setLayoutParams(new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    ImageView imageView = (ImageView) itemView.findViewById(R.id.viewpager_image);
  /*imageView.setLayoutParams(new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT,
            LinearLayout.LayoutParams.MATCH_PARENT));*/
    imageView.setImageResource(mResources[position]);
    container.addView(itemView);
    return itemView;
</code></pre>

<p>Doing this my width is matching the screen size but height is not matching screen. The layout I am inflating has Linear layout (width,height - MATCH_PARENT) and its child Image view (width,height - MATCH_PARENT). I don't know what wrong I am doing here.</p>