I'm making an app exclusively for android tablets and part of it has buttons dynamically created based on various news headlines. I have a single dimens.xml and I use the scaling factor from DisplayMetrics to make the sizes appropriate for different densities. The problem is that when I change the size in my xml it has absolutely no effect on the dimension that the method returns.
RelativeLayout.LayoutParams announcementButtonLayout = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
announcementButtonLayout.topMargin = topMargin;
announcementButtonLayout.addRule(RelativeLayout.ALIGN_PARENT_TOP);
announcementButtonLayout.height = this.getResources().getDimensionPixelSize(R.dimen.news_button_height);
announcementButtonLayout.width = getResources().getDimensionPixelSize(R.dimen.dashboard_right_width);
Button button = new Button (this.getActivity());
button.setWidth(getResources().getDimensionPixelSize(R.dimen.dashboard_right_width));
button.setBackgroundResource(R.drawable.photo_edited);
button.setTextColor(getResources().getColor(R.drawable.news_poll_item_text_color));
float f =Utilities.getPixelScaleMultiplier();
f *= getResources().getDimension(R.dimen.news_item_text);
button.setTextSize(f);
button.setText(announcement.getDescription());
button.setMaxLines(1);
button.setTag(announcement);
button.setOnClickListener(this);
button.setLayoutParams(announcementButtonLayout);
button.setId(index);
Based on my button code above, what could be causing this breach of trust?
Thanks,
Adurnari
EDIT: Included my LayoutParams as reference
Found the solution:
"Cleaning" was taking the values that I had changed in my xml and adding them on a later portion of the page where they were located previously. The lower ones were dictating the size.