2021年,玻璃效果UI正处于潮流之中。作为一名新的安卓开发者,我想在我的安卓应用程序中添加玻璃效果,因此我在谷歌上搜索了我的问题,但是并没有找到如何在我的安卓应用程序中添加玻璃效果的答案。
我需要编写代码来实现玻璃效果,还是可以通过xml设计简单地添加呢?
2021年,玻璃效果UI正处于潮流之中。作为一名新的安卓开发者,我想在我的安卓应用程序中添加玻璃效果,因此我在谷歌上搜索了我的问题,但是并没有找到如何在我的安卓应用程序中添加玻璃效果的答案。
我需要编写代码来实现玻璃效果,还是可以通过xml设计简单地添加呢?
android:alpha="0.6"
implementation 'com.eightbitlab:blurview:1.6.6'
<eightbitlab.com.blurview.BlurView
android:id="@+id/blur_view_tab"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:blurOverlayColor="@color/white_40">
<com.google.android.material.tabs.TabLayout
android:id="@+id/tab_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:tabMaxWidth="0dp"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabIndicatorColor="@color/black"
android:minHeight="?actionBarSize"/>
</eightbitlab.com.blurview.BlurView>
blurViewTab.setupWith(viewGroup)
.setBlurAlgorithm(RenderScriptBlur(context))
.setBlurRadius(16f)
.setBlurAutoUpdate(true)
.setHasFixedTransformationMatrix(true)
对于开发方面,我们可以使用 Glass Morphism、Soft UI 或其他风格进行转换或添加。它是在 Figma、Adobe XD 或其他一些具备设计原则的软件中开发的。之后,我们可以从设计师那里获取所需的资源,然后将这些资源用于我们的应用程序。