2011-11-18 41 views
3

底部我想要設計一個佈局,其中包含一個位於屏幕頂部的按鈕,當我們點擊按鈕時,它應該打開一個佈局,它來自底部像鍵盤一樣。設計一個像對話框一樣的對話框來自android

但不知道該怎麼做?

請分享您的想法做到這一點。佈局

屏幕截圖:

enter image description here

當我點擊該下拉按鈕,另一個佈局將來自下載一個大小的虛擬鍵盤。

感謝, Ammu

回答

2

動畫可以幫助你做到這一點:

private void initPopup() 
{ 

    final TransparentPanel popup = (TransparentPanel) findViewById(R.id.popup_window); 

    // Start out with the popup initially hidden. 
    popup.setVisibility(View.GONE); 


    animShow = AnimationUtils.loadAnimation(this, R.anim.popup_show); 
    animHide = AnimationUtils.loadAnimation(this, R.anim.popup_hide); 

    final Button showButton = (Button) findViewById(R.id.show_popup_button); 
    final Button hideButton = (Button) findViewById(R.id.hide_popup_button); 
    showButton.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      popup.setVisibility(View.VISIBLE); 
      popup.startAnimation(animShow); 
      showButton.setEnabled(false); 
      hideButton.setEnabled(true); 
    }}); 

    hideButton.setOnClickListener(new View.OnClickListener() { 
     public void onClick(View view) { 
      popup.startAnimation(animHide); 
      showButton.setEnabled(true); 
      hideButton.setEnabled(false); 
      popup.setVisibility(View.GONE); 
    }}); 


    final TextView locationName = (TextView) findViewById(R.id.location_name); 
    final TextView locationDescription = (TextView) findViewById(R.id.location_description); 

    locationName.setText("Animated Popup"); 
    locationDescription.setText("Animated popup is created by Arun nu solla mattaen" 
           + " Transparent layout is used on this example, and animation xml is also used" 
           + " on this example. Have a Good day guys."); 
} 

看到這個example

希望這有助於你。

+0

嘿,我已經看到了......使用代碼來自底部的佈局將佔據整個佈局。我只是想要它的高度 – Taruni