I Have a set button on a Linear Layout, and I set the button configuration programmatically.
buttonEdit = new ArrayList<ButtonData>();
buttonEdit.add(new ButtonData(1, "one", R.drawable.1));
buttonEdit.add(new ButtonData(2, "two", R.drawable.2));
buttonEdit.add(new ButtonData(3, "three", R.drawable.3));
buttonEdit.add(new ButtonData(4, "four", R.drawable.4));
buttonEdit.add(new ButtonData(5, "five", R.drawable.5));
LayoutParams lp=new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT);
for (ButtonData button : buttonEdit) {
Button btn = new Button(getApplicationContext());
btn.setId(button.getButtonID());
btn.setBackgroundResource(button.getBackgroundResource());
btn.setOnClickListener(buttonOnclickListener);
btn.setHeight(56);
btn.setWidth(48);
LinearLayout ll = new LinearLayout(getApplicationContext());
ll.setLayoutParams(lp);
ll.setOrientation(LinearLayout.VERTICAL);
ll.setPadding(10, 0, 10, 0);
btn.setGravity(Gravity.CENTER_HORIZONTAL);
TextView textLabel = new TextView(getApplicationContext());
textLabel.setText(button.getButtonName());
ll.addView(btn);
ll.addView(textLabel);
linearLayoutData.put(String.valueOf(button.getButtonID()), ll);
buttonObject.put(String.valueOf(button.getButtonID()), btn);
}
In list of code, I set a padding left and right 10. So the user can see a separate space between the buttons. So the problems is, when I install the apps in Multiple Resolutions (QVGA, HVGA, WVGA) it is spaced differently. In QVGA it's wider and in WVGA it's narrower. What will I do?