更改进度条以外的布局不透明度

问题描述 投票:0回答:2

我有一个使用圆形进度条的应用程序。

我想更改整个布局的不透明度,直到完成加载。

类似这样的东西:

enter image description here

我设法使用以下方法更改布局的不透明度:

cl = findViewById( R.id.Discover_Layout );
cl.setAlpha( 0.45f );

但是,它也会同时更改ProgressBar的不透明度。

我尝试使用:

cl = findViewById( R.id.Discover_Layout );
cl.setAlpha( 0.45f );

pb_Discover = findViewById( R.id.pb_Discover );
pb_Discover.setVisibility( View.VISIBLE );
pb_Discover.setAlpha( 1f );

但是它仍然使ProgressBar具有不透明度。

如何从布局不透明度中排除ProgressBar

谢谢

java android android-constraintlayout android-progressbar
2个回答
0
投票

我假设Discover_Layout是包含pb_Discover进度条的父级布局。因此,更改父级不透明度也会反映在子级视图中。您可以创建framelayout作为父级布局,然后将Discover_Layout和pb_Discover添加为2个单独的子级视图。因此Discover_Layout的不透明度更改不会影响pb_Discover进度栏。

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_layout_badge"
android:layout_width="match_parent"
android:layout_height="match_parent">

< ----Discover_Layout---/>

< ----pb_Discover---/>

</FrameLayout>

以这种方式命名视图ID最好以小写字母开头


0
投票

我认为您的发现布局是进度视图的父级。您必须使背景视图变得不透明。

© www.soinside.com 2019 - 2024. All rights reserved.