1

I use padding in one of my layouts. More precisely it's a component defining one item which I use in two different list views in my application. Today when preparing the new version of my program, I noticed very strange thing.

Padding works without problems in android 4.0.4 (in case of two list views). Padding seems to be ignored in first list view, and works ok in the second list view in android 4.2.2.

Moreover I didn't touch this layout definition since many days so it's quite surprising it stopped to work. Android bug? Eclipse bug?

I tried to clean project, restart eclipse etc. Nothing helps...

Any ideas?

user2707175
  • 1,133
  • 2
  • 17
  • 44

1 Answers1

1

FInally I've found the reason - In case of one of listviews I use setBackgroundResourceand it seems that Android here has a bug....:

The solution which helped:

if(condition) {
    int bottom = theView.getPaddingBottom();
    int top = theView.getPaddingTop();
    int right = theView.getPaddingRight();
    int left = theView.getPaddingLeft();
    theView.setBackgroundResource(R.drawable.entry_bg_with_image);
    theView.setPadding(left, top, right, bottom);
}

more: setBackgroundResource() discards my XML layout attributes

Community
  • 1
  • 1
user2707175
  • 1,133
  • 2
  • 17
  • 44