Search code examples
javaandroidxmlandroid-layoutandroid-screen

Filling screen Android dont work with S3 S4 screen resolution


i am having the following issue, when i use s2 the image takes all the background of the screen(that is what i want), but when i use an s3 or s4, or galaxy note for example, it only fills a quarter of the screen... It only fits well in 480 x 800...I have been with this issue for hours...

Here is the code where it set the params...

                LinearLayout lLayout = new LinearLayout(mContext);
                lLayout.setLayoutParams(new LinearLayout.LayoutParams(
                        LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
                lLayout.setBackgroundDrawable(((ImageView)mView).getDrawable());
                mlayout.addView(lLayout);

If i harcode the layout params to take 1080 x 1980 it works well in s4... but that is not a solution...

Can anyone help me with this issue plis?


Solution

  • Try this:

    after mLayout.addView add

    mLayout.forceLayout();

    if not work:

    mLayout.forceLayout();

    mLayout.invalidate();

    good luck