当前位置:网站首页>Realize the function of progress bar through layerdrawable
Realize the function of progress bar through layerdrawable
2022-04-23 01:30:00 【Jianren Yinkou】
The renderings are as follows :

First, the background picture is as follows , The bottom layer is the background , The upper layer is the color of the progress bar
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="6dp" />
<solid android:color="#23252c" />
</shape>
</item>
<item android:width="0dp" android:id="@+id/progress_bg">
<shape android:shape="rectangle">
<gradient android:startColor="#006580df"
android:endColor="#ff6580df"
android:angle="0"/>
<corners android:topLeftRadius="6dp"
android:bottomLeftRadius="6dp"/>
</shape>
</item>
</layer-list>
Then pass the progress value , Dynamically modify the width of the upper picture of the above picture , The processing logic is as follows :
LayerDrawable rootBg = (LayerDrawable) mRootView.getBackground();
Drawable progressBg = rootBg.findDrawableByLayerId(R.id.progress_bg);
progressBg.setBounds(0, 0,(int) (mRootView.getWidth() * progress / 100L), getHeight());
The key code is findDrawableByLayerId, Through this method, the function can get LayerDrawable A picture of a layer required in . Update the drawable Of bound That is to say .
版权声明
本文为[Jianren Yinkou]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220942099326.html
边栏推荐
- Branch and loop statements
- 轮转法分片
- 计蒜客:数独(DFS)
- The code bought from the salted fish | SSM hotel room management system | whether the purchased source code can really be used | confusion from the programmer | Yu Nianyu Hui | Wu Minghui, dachou Vill
- 那些咸鱼上买来的代码|ssm酒店客房管理系统|买来的源码是否真的可以使用|来自程序员的困惑|玉念聿辉|大丑村吴明辉
- Rotation slice
- Update description of the latest process engine flowable 6.7.2
- Gbase 8s客户端与服务器的通信
- gin框架的学习--golang
- Chris LATTNER, father of llvm: the golden age of compilers
猜你喜欢

Three technical solutions of ant group were selected as "typical solutions for information technology application and innovation in 2021"

On regular expression matching cryptography

gin框架的学习--golang

Detonate the bomb (DFS)

(product resources) mingdeyang ad8488 module high performance digital X-ray FMC interface 128 analog channel high-speed ADC chip

Linked list dynamic header insertion

全排列(DFS和next_permutation解法)

VS+C# 实现窗体输入框默认显示灰色文字

Abused "architect"!

Basic knowledge of software testing (detailed version) collection of this article is enough
随机推荐
Activity preview | on April 23, a number of wonderful openmldb sharing came, which lived up to the good time of the weekend!
World reading day: 18 it books with Douban score above 9.0 are worth collecting
Software maintenance exercises
How to introduce SPI into a project
Redis forgets the password and resets the password
GBase 8t索引
Unity combines itextsharp to generate PDF preparation DLL
智能手表的下半场,机遇与挑战并存
Garlic Junkai company (DFS full arrangement)
Find number (DFS)
Is it difficult for girls to learn software testing?
In the second half of the smart watch, opportunities and challenges coexist
Gbase 8s检查点简介
Learning of gin framework -- golang
Traversal of ladder race l2-6 tree
计蒜客:方程的解数
Interview eight part essay (disorderly order, no classification)
Zhang Jian of Huawei cloud IOT expert group: he has become a senior engineer of Huawei since he was 22. The code is what I want to say to the world
代码实现发邮件---sendemails
Let's talk about passive safety again. I'll teach you to understand the rating report of China Insurance Research Institute collision test