如何在另一个布局上放置透明视图
How to put a transparent view on another Layout
我正在研究表面视图。我想要我的表面视图上有一个透明视图。该透明视图必须包含标题、描述和微调器三样东西和一个按钮名称 "Start"。如果不输入标题、描述和 Spinner 的菜单,就无法进入透明视图下方的下一个布局。请帮我举一些例子..如何实现这种观点???这就是我想要的.. enter image description here
这是我的 Surfaceview 布局..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
使用FrameLayout
代替RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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"
tools:context=".MainActivity">
// Add other view
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
</FrameLayout>
你可以像这样使用
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
<view
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"/>
</RelativeLauout>
You can place FrameLayout
<?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="match_parent">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
</RelativeLayout>
or You can place View
<?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="match_parent">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</View>
</RelativeLayout>
FrameLayout is the better option
使用RelativeLayout或FrameLayout你可以在SurfaceView上面放置另一个布局,使布局透明,使下面的SurfaceView部分可见,我们必须将alpha设置为layout.We的背景颜色才能使通过更改颜色代码实现特定颜色透明。
一般颜色代码都是这种格式,
RR GG BB 或 R G B
例如: # ff 00 00 或 # f f 0
它告诉绿色蓝色红色值从 0 到 f(十六进制)
我们有另一种颜色代码格式来设置 alpha 值以更改颜色的不透明度,
AA RR GG BB 或 A R G B
例如:# ff ff 00 00 或 #0 f f 0
它告诉 Alpha Green Blue Red 值从 0 到 f(十六进制)
因此,为了使任何颜色透明,我们可以将 alpha 的值从 0 更改为 f。
例如:假设我们想让黑色透明,
黑色的颜色代码是 #000000
,要使其透明,请将其更改为
#00000000
- 完全透明
#88000000
- 部分透明
#ff000000
- 无透明度
将此颜色设置为您的布局以使其透明。
我正在研究表面视图。我想要我的表面视图上有一个透明视图。该透明视图必须包含标题、描述和微调器三样东西和一个按钮名称 "Start"。如果不输入标题、描述和 Spinner 的菜单,就无法进入透明视图下方的下一个布局。请帮我举一些例子..如何实现这种观点???这就是我想要的.. enter image description here
这是我的 Surfaceview 布局..
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
使用FrameLayout
代替RelativeLayout
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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"
tools:context=".MainActivity">
// Add other view
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
</FrameLayout>
你可以像这样使用
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context=".MainActivity">
<LinearLayout
android:id="@+id/suface_view_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<net.ossrs.yasea.SrsCameraView
android:id="@+id/glsurfaceview_camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true" />
</LinearLayout>
<view
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent"/>
</RelativeLauout>
You can place FrameLayout
<?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="match_parent">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</FrameLayout>
</RelativeLayout>
or You can place View
<?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="match_parent">
<SurfaceView
android:id="@+id/surfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
>
</View>
</RelativeLayout>
FrameLayout is the better option
使用RelativeLayout或FrameLayout你可以在SurfaceView上面放置另一个布局,使布局透明,使下面的SurfaceView部分可见,我们必须将alpha设置为layout.We的背景颜色才能使通过更改颜色代码实现特定颜色透明。
一般颜色代码都是这种格式,
RR GG BB 或 R G B
例如: # ff 00 00 或 # f f 0
它告诉绿色蓝色红色值从 0 到 f(十六进制)
我们有另一种颜色代码格式来设置 alpha 值以更改颜色的不透明度,
AA RR GG BB 或 A R G B
例如:# ff ff 00 00 或 #0 f f 0
它告诉 Alpha Green Blue Red 值从 0 到 f(十六进制)
因此,为了使任何颜色透明,我们可以将 alpha 的值从 0 更改为 f。 例如:假设我们想让黑色透明,
黑色的颜色代码是 #000000
,要使其透明,请将其更改为
#00000000
- 完全透明#88000000
- 部分透明#ff000000
- 无透明度
将此颜色设置为您的布局以使其透明。