Android 如何使布局半透明?
我正在尝试在容器主目录中创建一个可滚动的选项卡。我正在使图像模糊 但我想显示半模糊和半彩色 在第二个我想显示模糊的背景,在另一半的材料设计颜色“没有阿尔法” 如何设置此选项 这是我的容器主代码Android 如何使布局半透明?,android,android-layout,Android,Android Layout,我正在尝试在容器主目录中创建一个可滚动的选项卡。我正在使图像模糊 但我想显示半模糊和半彩色 在第二个我想显示模糊的背景,在另一半的材料设计颜色“没有阿尔法” 如何设置此选项 这是我的容器主代码 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.union.front1.MainActivity"
tools:showIn="@layout/activity_main">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pager"
android:background="#060606">
<android.support.v4.view.PagerTitleStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/Base.TextAppearance.AppCompat.Widget.ActionBar.Title"
android:id="@+id/title"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:layout_gravity="top"
android:background="#000"
style="@style/AppTheme.my"
android:layout_marginTop="15dp"/>
</android.support.v4.view.ViewPager>
</RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:id="@+id/imageView"
android:alpha="0.8"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
这是我的片段代码
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.example.union.front1.Album"
android:background="#e5060606">
<es.guiguegon.sineview.SineView
android:id="@+id/sine_view_album"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:sv_sine_alpha="1"
app:sv_sine_amplitude="25dp"
app:sv_sine_animation_time_millis="2000"
app:sv_sine_color="@color/colorPrimaryDark"
app:sv_sine_periods_to_show="2"
app:sv_sine_phase="1" />
</RelativeLayout>
如何将布局的一半设置为透明,一半设置为强颜色我所做的错误是我将imageview放置在viewpager下面,这意味着图像视图层将位于viewpager层之上,因此我将imageview层放置在viewpager层之上,这样我就不必设置图像的alpha,它将显示背景中的图像。当我在片段中使用强烈的颜色时,它将保持强烈,因为我没有在图像视图中使用alpha`
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="com.example.union.front1.MainActivity"
tools:showIn="@layout/activity_main">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:id="@+id/imageView"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />`
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/pager"
android:background="#060606"
>
<android.support.v4.view.PagerTitleStrip
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="@style/Base.TextAppearance.AppCompat.Widget.ActionBar.Title"
android:id="@+id/title"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:layout_gravity="top"
android:background="#000"
style="@style/AppTheme.my"
android:layout_marginTop="15dp"
/>
</android.support.v4.view.ViewPager>
</RelativeLayout>
</RelativeLayout>
`