iT邦幫忙

2021 iThome 鐵人賽

DAY 15
0
自我挑戰組

才30天?一個月學會Android開發系列 第 15

Day-15 FrameLayout

FrameLayout(幀布局)
FrameLayout是佈局當中最簡單的一個,
在未設定的情況下,
所有原件皆會於左上方開始顯示,
最先的原件會放於最底端而最後的原件放在最上面,
就如同堆疊的方式顯示


<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">

    <TextView
        android:layout_width="300dp"
        android:layout_height="200dp"
        android:background="#000000" />
    <TextView
        android:layout_width="250dp"
        android:layout_height="150dp"
        android:background="#FFFFFF" />
    <TextView
        android:layout_width="200dp"
        android:layout_height="100dp"
        android:background="#000000" />
    
</FrameLayout>

https://ithelp.ithome.com.tw/upload/images/20210926/20141950ZxTdlC4VPM.png
我們新增了三個不同大小的文字方塊,
由大到小排列,
因此在執行的畫面中可看出,
三個文字方塊於左上角以堆疊的方式呈現,
同時小的在上而大的在下,
以上就是FrameLayout最簡單的範例。


上一篇
Day-14 TableLayout
下一篇
Day-16 AbsoluteLayout
系列文
才30天?一個月學會Android開發30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言