2012-04-02 7 views
0

私は初心者プログラミングアンドロイドです。現在のウィンドウレイアウトで透過的なサブビューを作成する方法について情報を探しています。xmlレイアウトでいくつかのビューのサブビューを追加するには

私はこれが元であるシンプルなレイアウトを作成しました:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Simple text" /> 

</LinearLayout> 

は、今私は、ナビゲーションボタンが押されたときにビューを作成したいです。そのビューは透明で約40%のレイアウトの上に追加したいと考えています。

enter image description here

はまた、他のボタン、ドロップボックスまたはを追加するのは簡単であるべきと私は簡単に、このビューを削除することができます:それはこのようになります。

誰かがこれを行い、私がアイデアを共有できるかどうか、どうすればよいですか?

ありがとうございました。

+0

他のビューで1つのビューを表示するには、RelativeLayoutを使用します。 –

答えて

0

チェックアウトこれとは行うプログラム的

view.getBackground().setAlpha(100); // to make background transparent 
View mainview ; 
PopupWindow popupwindow; 


public void onCreate(Bundle savedInstanceState){ 

LayoutInflater inflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

    mainview = inflater.inflate(R.layout.main, null, false); 
    setContentView(mainview); 

    // load sub menu from xml layout in popupwindow 
     View submenu_popup = inflater.inflate(R.layout.submenu_popup, null, false); 

// make backgraound transparent of popup submenu 
     submenu_popup.getBackground().setAlpha(100); 

     popupwindow = new PopupWindow(submenu_popup ,300,300,false); 
     popupwindow.setOutsideTouchable(true); 
     popupwindow.setTouchable(true); 

} 


// call it on click of button or menu to show submenu 
public void onClickButton(){ 

    int x=0,y=0; 
// show popupwindow on x, y position in main view (parent view) by using this 
    popupwindow.showAtLocation(mainview , Gravity.NO_GRAVITY, x, y); 

} 
0

を次のようにあなたが使用する方法を学ぶ必要があるかもしれませ親ビューの上部に表示するPopupWindowを使用することができます

「アンドロイド:テーマ」プロパティ

関連する問題