Как установить ширину обзора относительно значения в android - PullRequest
0 голосов
/ 03 августа 2020

enter image description here

How to change the second view length according to value. If the first one value is 100 then the width is match_parent. If the second one value is 60 then how to set the width of that according to that one.

                 

1 Ответ

0 голосов
/ 03 августа 2020

Вы можете использовать ProgressBar, но если вам действительно нужно go на этом пути, вы можете установить ширину зеленой полосы, например:

View viewGray, viewGreen;
int currentValue, totalValue;
//Some relevant code
viewGray.postDelayed(new Runnable() {
            @Override
            public void run() {
                int parentWith = viewGray.getWidth();
                int viewGrayWith = parentWith * (currentValue/(float)totalValue);
                viewGreen.getLayoutParams().width = viewGrayWith;
            }
        },50);


    
    
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...