2016-04-11 14 views
1

Uygulamamda camerapopup.xml dosyası oluşturuyorum. Tüm ekran boyutu için ekranın altındaki bu pencereyi görüntülemek istiyorum. Farklı düzen klasörleri (düzen-büyük, düzen-küçük, layoutxlarge vb) oluşturmaya çalıştım ama hiç çalışmıyor. Altta tüm ekran boyutu için açılır pencere nasıl ayarlanır. Birisi bana bununla nasıl çalışılır yardımcı olabilir. Şimdiden teşekkürler .Android'de tüm ekran boyutunun altında açılır pencere nasıl ayarlanır?

İşte benim xml dosyasım.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/popup_element" 
    android:layout_width="fill_parent" 
    android:layout_height="180dp" 
    android:background="@android:color/transparent" 
    android:orientation="vertical" 
    android:padding="3dp"> 


    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="1dp" 
     android:background="@android:color/transparent" 
     android:orientation="vertical"> 

     <TextView 
      android:id="@+id/Title" 
      android:layout_width="fill_parent" 
      android:layout_height="40dp" 
      android:layout_gravity="center_horizontal" 
      android:layout_weight="1" 
      android:background="@drawable/curve_shap" 
      android:gravity="center_horizontal|center_vertical" 
      android:text="Take Photo" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:textColor="@android:color/darker_gray" 
      android:textSize="14sp" /> 

     <Button 
      android:id="@+id/button_Camera" 
      android:layout_width="fill_parent" 
      android:layout_height="40dp" 

      android:layout_gravity="center_horizontal" 
      android:layout_weight="1" 
      android:background="@drawable/curve_shap" 
      android:text="Camera" 
      android:textColor="#3A86CF" /> 

     <Button 
      android:id="@+id/button_Gallery" 
      android:layout_width="fill_parent" 
      android:layout_height="40dp" 
      android:layout_gravity="center_horizontal" 
      android:layout_weight="1" 
      android:background="@drawable/curve_shap" 
      android:text="Gallery" 
      android:textColor="#3A86CF" /> 


    </LinearLayout> 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="45dp" 
     android:layout_marginTop="4dp" 
     > 

     <Button 
      android:id="@+id/btnCancelCamera" 
      android:layout_width="fill_parent" 
      android:layout_height="40dp" 
      android:layout_gravity="center_horizontal" 

      android:background="@drawable/curve_shap" 
      android:text="Cancel" 
      android:textColor="#3A86CF" 
      android:textSize="16sp" 
      android:textStyle="bold" /> 
    </RelativeLayout> 


</LinearLayout> 

Burada, benim Etkinlik kodu

imgProfilePic.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 

LayoutInflater layoutInflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE); 
       View popupView = layoutInflater.inflate(R.layout.camera_popup, (ViewGroup) findViewById(R.id.popup_element)); 
       popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); 
       popupWindow.setWidth(720); 
       popupWindow.setHeight(350); 
       popupWindow.setFocusable(true); 
       popupWindow.showAtLocation(popupView, Gravity.BOTTOM, 0, 0); 
       popupWindow.setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); 

       Button btnCamera = (Button) popupView.findViewById(R.id.button_Camera); 
       Button btnGallery = (Button) popupView.findViewById(R.id.button_Gallery); 
       Button btnDismiss = (Button) popupView.findViewById(R.id.btnCancelCamera); 
} 
     }); 

cevap

5
Use this in all your java file 

AlertDialog.Builder builder = new AlertDialog.Builder(context); 
     LayoutInflater inflater = ((Activity) context).getLayoutInflater(); 
     View dialogLayout = inflater.inflate(R.layout.ppopup_element, 
       null); 

     final AlertDialog dialog = builder.create(); 
     dialog.getWindow().setSoftInputMode(
       WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); 
     dialog.setView(dialogLayout, 0, 0, 0, 0); 
     dialog.setCanceledOnTouchOutside(true); 
     dialog.setCancelable(true); 
     WindowManager.LayoutParams wlmp = dialog.getWindow() 
       .getAttributes(); 
     wlmp.gravity = Gravity.BOTTOM; 


      Button btnCamera = (Button) dialogLayout.findViewById(R.id.button_Camera); 
      Button btnGallery = (Button) dialogLayout.findViewById(R.id.button_Gallery); 
      Button btnDismiss = (Button) dialogLayout.findViewById(R.id.btnCancelCamera); 


     builder.setView(dialogLayout); 

     dialog.show(); 
+0

Merhaba cevap için teşekkürler olduğunu. Kodunuzu ve çalışmayı denedim, ancak bazı küçük problemler bana AlertDialog.Builder'in genişliğini dolgu ebeveyni olarak nasıl ayarlayacağınızı söyleyebilir misiniz? – jandroid

+0

WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); \t \t Pencere Penceresi = dialog.getWindow(); \t \t \t lp.copyFrom (window.getAttributes()); \t \t lp.width = WindowManager.LayoutParams.MATCH_PARENT; \t \t lp.height = WindowManager.LayoutParams.WRAP_CONTENT; \t \t \t lp.gravity = Gravity.BOTTOM; \t \t \t window.setAttributes (lp); –

+0

Çalıştığı için teşekkürler. – jandroid

İlgili konular