With api 25, there is no problem, but with api 17, the elements simply do not respond to setLayoutParams, setWidth, and so on. What should be done in this case?


Yes, simple code - in the emulator with api 25 works, with api 17 does not work.

FrameLayout ht1 = (FrameLayout) ty.getChildAt(c); TextView tv = (TextView) ht1.getChildAt(0); tv.setLayoutParams(new FrameLayout.LayoutParams(len,FrameLayout.LayoutParams.MATCH_PARENT)); 

Also, setWith does not work, and so on, that is, the parameters change, but the element is not drawn again. I remember that I did something with the mesure method, it seemed to work, but now I don’t remember how it is done in detail.

  • try replacing FrameLayout.LayoutParams with ViewGroup.LayoutParams - Serodv
  • Changed, nothing has changed, only when you turn the screen (an event is caught), an error flies. android.view.ViewGroup $ LayoutParams cant be cast to android.view.ViewGroup $ MarginLayoutParams - PN GH
  • LayoutParams lp = tv.getLayoutParams (); lp.width = len; tv.requestLayout (); and if so? - Serodv
  • All the old, except that the error does not crash when you rotate the screen. The scheme is approximately the same: changing the pages of an application is done with the help of inflateLayout (XML layouts), and not with the help of creating new activities. On the problem page, elements are added dynamically, while the size of one element adjusts to the size of another. Also, the event rotates the screen - and the same adjustment of the elements goes. Activity is not overloaded when you rotate the screen (turned off). Such a scheme works well with api 25, but with api 17, no, that is, an attempt to resize does not dynamically work. - PN GH
  • I have no complaints about the scheme, I use it myself. The last thing I can offer is to stick this code snippet into tv.post () for example. - Serodv

0