Method for dynamically modifying width and height of relativelayout in Android programming

This article describes the method of dynamically modifying the width and height of relativelayout in Android programming. Share with you for your reference, as follows:

We often dynamically modify the width and height of relativelayout. This code is relatively simple, that is, modify the layoutparams of relativelayout. The code is generally as follows:

In most cases, this modification has no problem and is easy to use, but the problem I encounter is that the relativelayout I want to modify is the middle part of the whole layout

What I want to modify here is the green life box in the middle. If we use the above method, you will find that the height of the relativelayout has indeed been changed, but it has changed the overall layout and eliminated the top row of toolbars. It is as follows

This is not what we want. How to change this. In fact, you can understand by looking at the code carefully. In the above method, it creates a layoutparams. The problem is here. The correct method is to obtain -- > Modify -- > and then set it

The code is as follows:

Try again this time, as shown in the figure

I hope this article will help you in Android programming.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>