2013-03-29 28 views
0

我想創建一個僅包含一個按鈕的佈置的配置,我想要的佈局是透明更甚至更多,我想這是不是在那裏「,換句話說,我希望我的佈局只是一個不是完整大小的「窗口」,而只是按鈕大小,所以我將能夠繼續使用在我的應用程序後面打開的任何應用程序。創建唯一的按鈕,透明背景的Android

我嘗試:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="wrap_content" 
android:layout_height="wrap_content" 
android:windowBackground="@android:color/transparent" 
android:windowIsTranslucent="true" > 

<ToggleButton android:id="@+id/lockButton" 
    style="@style/lockToggle" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true"> 
</ToggleButton> 

背景是真正透明的,但仍然是一個層並在背面的應用程序是不可用的。

+0

你在後臺的應用程序無法使用,因爲只要你打開這個程序,你要創建,任何其他應用前景將進入它的'onPause'狀態(我相信它甚至會去'onStop'),您將不再能夠與它進行交互在這種情況下。檢查[這裏](http://www.herongyang.com/Android/Activity-onCreate-and-Callback-Methods.html)以獲取更多關於應用程序的生命週期。據我所知,這是不可能的...... – TronicZomB

+1

您是否需要這樣的: http://stackoverflow.com/questions/2176922/how-to-create-transparent-activity-in-android? – nfirex

+0

或者這個:https://github.com/pingpongboss/StandOut? – nfirex

回答