使用RelativeLayout布局做成顶部和底部透明,设置如下:
位置不能出现错位,如果先把header放上面,后面的会把前面的部分覆盖,类似CSS的3D模型
<?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">
<android.support.v4.view.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- 顶部布局 -->
<RelativeLayout
android:id="@+id/header"
android:layout_width="match_parent"
android:layout_height="@dimen/display_photo_bottom_height"
android:layout_alignParentTop="true"
android:background="#ac080808">
</RelativeLayout>
<!-- 底部布局 -->
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_alignParentBottom="true"
android:background="#ac080808">
</RelativeLayout>
</RelativeLayout>
位置不能出现错位,如果先把header放上面,后面的会把前面的部分覆盖,类似CSS的3D模型
本文介绍如何使用RelativeLayout实现Android应用中顶部和底部透明效果的布局方案。通过调整布局属性及使用半透明背景色,确保各部分不会出现错位,并保持良好的视觉效果。
1万+

被折叠的 条评论
为什么被折叠?



