Android中FrameLayout總結

來源:互聯網
上載者:User

標籤:

今天在學習實現墨跡天氣那樣的拖動效果時,看到用的是重寫FrameLayout

FrameLayout布局是最簡單的布局方式,所有添加到這個布局中的視圖都是以層疊的方式顯示。第一個添加到布局中視圖顯示在最底層,最後一個被放在最頂層。上一層的視圖會覆蓋下一層的視圖,因此該布局類似於堆棧布局。注意點:a.預設對其方式是左上方對齊。b.若要設定子視圖的位置,要設定layout_gravity屬性值。

 1 <?xml version="1.0" encoding="utf-8"?> 2 <FrameLayout 3     xmlns:android="http://schemas.android.com/apk/res/android" 4     android:layout_width="fill_parent" 5     android:layout_height="fill_parent" 6     android:background="#897753" 7     > 8     <ImageView  9         android:id="@+id/image1"10         android:layout_width="fill_parent"11         android:layout_height="fill_parent"12         android:visibility="invisible"13         android:src="@drawable/sky"/>14     <ImageView 15         android:id="@+id/image2"16         android:visibility="invisible"17         android:layout_width="fill_parent"18         android:layout_height="fill_parent"19         android:src="@drawable/cloud"/>20     <ImageView 21         android:id="@+id/image3"22         android:visibility="invisible"23         android:layout_width="fill_parent"24         android:layout_height="fill_parent"25         android:src="@drawable/sun"/>26 27 </FrameLayout>

其中,image1、image2、image3都是在同一塊空間的。可以說它們是重疊著的,介面顯示的是最近用的那一個。

Android中FrameLayout總結

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.