0

I am making UI in android using java code because all UI information comming from server so we can't use xml but there is problem when I create 7 button on screen by giving information it is supporting ldpi but rest of devices it is not working code is as-

for (int index = 0; index <7; index++) {


        Button objwidgetbutton = new Button(this);


        LinearLayout.LayoutParams objlayoutbtnparams = new LinearLayout.LayoutParams(280,LinearLayout.LayoutParams.WRAP_CONTENT); // Verbose!

        objwidgetbutton.setText("hiii");

        objwidgetbutton.setBackgroundResource(R.drawable.ic_launcher);

        llinner.addView(objwidgetbutton,objlayoutbtnparams);

    }
    objlinear.addView(llinner);

I am using this structure is as

<LinearLayout>
  <LinearLayout>
   <button/>#7
  </LinearLayout>
  </LinearLayout>

Please guide me Is I going right path or doing other things?Main things is that how to make screen support all resolution

LOOSER
  • 215
  • 1
  • 2
  • 10

1 Answers1

1

You probably want to set up some different methodologies for each of the different pixel densities. See this solution to another question. Adapt your code to work with different pixel densities, and put them in the case statements.

Community
  • 1
  • 1
gobernador
  • 5,659
  • 3
  • 32
  • 51