Android 在模糊布局中不模糊文本视图
我试图在黑色透明层上放置一些文本视图。 为了使布局模糊,我在布局内部设置了alpha(0.3) 它工作得很好。布局变得透明。 但问题是,布局中的文本视图也变得模糊。 我怎样才能修好它Android 在模糊布局中不模糊文本视图,android,Android,我试图在黑色透明层上放置一些文本视图。 为了使布局模糊,我在布局内部设置了alpha(0.3) 它工作得很好。布局变得透明。 但问题是,布局中的文本视图也变得模糊。 我怎样才能修好它 <LinearLayout android:layout_width="match_parent" android:layout_height="30dp" android:background="#E6000000" android:alpha="0.3" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#E6000000"
android:alpha="0.3"
>
<TextView
android:id="@+id/text_feed_myPlant_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Error"
android:textSize="19dp"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_feed_myPlant_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#FFFFFF"
android:gravity="right"
android:layout_gravity="center_vertical"
android:paddingRight="10dp"
android:layout_weight="1.5"/>
</LinearLayout>
您可以做的是选择一个相对布局,然后选择一个涵盖所有布局的视图,并将aplha设置为该视图。然后,您可以选择线性布局,并将其设置为相对布局的第二个子级
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.3"
android:background="#E6000000"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="30dp"
>
<TextView
android:id="@+id/text_feed_myPlant_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="Error"
android:textSize="19dp"
android:textColor="#FFFFFF"
android:layout_marginLeft="10dp"
android:layout_gravity="center_vertical"
android:layout_weight="1"/>
<TextView
android:id="@+id/text_feed_myPlant_time"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:textSize="14dp"
android:textColor="#FFFFFF"
android:gravity="right"
android:layout_gravity="center_vertical"
android:paddingRight="10dp"
android:layout_weight="1.5"/>
</LinearLayout>
</RelativeLayout>
我这样做了,效果很好。我认为这并不是最好的做法。但它会解决你的问题
<FrameLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E6000000"
android:alpha="0.3"
>
<TextView
/>
<TextView
/>
</LinearLayout>
介意添加一个清晰的屏幕截图吗?尝试不使用alpha,而使用8000000作为父布局颜色