背景模糊,仅在Android中使用XML

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

我将FrameLayout用于不同的布局层。这是我的代码:

<FrameLayout>

  <!-- Bottom layer -->
  <RelativeLayout>
      // some views and viewgroups
  </RelativeLayout>



  <!-- Middlelayer -->
  <RelativeLayout>
      // this layer will be empty.
      // I want to make this layer like frosted glass to get blur effect
  </RelativeLayout>



  <!-- Top layer -->
  <RelativeLayout>
      // some views
  </RelativeLayout>
</FrameLayout>

这是我想要的样子:

enter image description here

我想使中间层像毛玻璃一样,使底层看起来很模糊。如何仅使用xml来实现? (如果无法仅使用xml,请用Java代码帮助我)

android android-framelayout
1个回答
0
投票

您可以在XML中使用alpha属性

android:alpha="0.5"

或只是代码中的背景色

v.setBackgroundColor(0xFF00FF00);

v是您的中间层的地方

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