Android布局管理器-使用FrameLayout帧布局管理器显示层叠的正方形以及前景照片
生活随笔
收集整理的這篇文章主要介紹了
Android布局管理器-使用FrameLayout帧布局管理器显示层叠的正方形以及前景照片
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
場景
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"><TextViewandroid:layout_width="280dp"android:layout_height="280dp"android:text="藍色背景"android:textColor="#FFFFFF"android:background="#FF0000FF"/><TextViewandroid:layout_width="230dp"android:layout_height="230dp"android:text="天藍色背景"android:textColor="#FFFFFF"android:background="#FF0077FF"/><TextViewandroid:layout_width="180dp"android:layout_height="180dp"android:text="水藍色背景"android:textColor="#FFFFFF"android:background="#FF00B4FF"/></FrameLayout>?
總結
以上是生活随笔為你收集整理的Android布局管理器-使用FrameLayout帧布局管理器显示层叠的正方形以及前景照片的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android布局管理器-使用Linea
- 下一篇: Android布局管理器-使用Table