場景
Android布局管理器-使用LinearLayout實作簡單的登錄視窗布局:
https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/103838995
幀布局管理器FrameLayout

實作效果

注:
博客:
https://blog.csdn.net/badao_liumang_qizhi
關注公眾號
霸道的程式猿
獲取編程相關電子書、教程推送與免費下載,
實作
將activity_main.xml修改為FrameLayout

然后通過
android:foreground="@drawable/dog"
設定其前景照片,就是位于所有控制元件的最上方的照片,
其中照片是位于res/drawable下的dog.jpg

然后通過
android:foregroundGravity="right|bottom"
設定前景照片位置,多個位置使用|分割,這里是設定位于右邊和下邊,
然后依次設定不同大小的TextView以及不同的北京顏色,實作層疊效果,
完整代碼如下
<?xml version="1.0" encoding="utf-8"?> <FrameLayout 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" android:foreground="@drawable/dog" android:foregroundGravity="right|bottom" tools:context=".MainActivity"> <TextView android:layout_width="280dp" android:layout_height="280dp" android:text="藍色背景" android:textColor="#FFFFFF" android:background="#FF0000FF" /> <TextView android:layout_width="230dp" android:layout_height="230dp" android:text="天藍色背景" android:textColor="#FFFFFF" android:background="#FF0077FF" /> <TextView android:layout_width="180dp" android:layout_height="180dp" android:text="水藍色背景" android:textColor="#FFFFFF" android:background="#FF00B4FF" /> </FrameLayout>
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/41507.html
標籤:Android
