簡體   English   中英

如何在Android中創建疊加布局

[英]How to create Overlay layout in android

如何創建布局像我附着在后台正常的任何layout.From該布局當我點擊任何或回到該布局,覆蓋布局應該有任何表單字段按鈕或文字...任何

提前致謝。

在此處輸入圖片說明

使用RelativeLayout或FrameLayout。 最后一個子視圖將覆蓋其他所有內容。

為確保覆蓋視圖在頂部,您可以在相對布局上調用ViewGroup.bringChildViewToFront()

例:

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:id="@+id/root_view">

    <EditText
        android:layout_width="fill_parent"
        android:id="@+id/editText1"
        android:layout_height="fill_parent">
    </EditText>

    <EditText
        android:layout_width="fill_parent"
        android:id="@+id/editText2"
        android:layout_height="fill_parent">
        <requestFocus></requestFocus>
    </EditText>

</FrameLayout>

在此布局中,editText2將覆蓋editText1

我相信您應該使用FrameLayout ,可以在另一個對象之前添加對象。 請在文檔中閱讀。

    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/root_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

        <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
        <!-- other actual layout stuff here  -->

       </LinearLayout>

    <LinearLayout
    android:id="@+id/overlay"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="right" >
    </LinearLayout>

    </FrameLayout>

現在,您在LinearLayout下使用android:id = "@+id/overlay"添加的任何視圖將顯示為重力= right的覆蓋

希望這對您有幫助

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM