Ich erstelle camerapopup.xml in meiner Anwendung. Ich möchte dieses Popup-Fenster am unteren Bildschirmrand für alle Bildschirmgrößen anzeigen. Ich habe versucht, verschiedene Layout-Ordner (layout-large, layout-small, layoutxlarge usw.) zu erstellen, funktioniert aber überhaupt nicht. Wie setze ich das Popup-Fenster für alle Bildschirmgrößen am unteren Rand. Kann mir jemand helfen, damit zu arbeiten. Danke im Voraus .Wie wird ein Popup-Fenster am unteren Rand der gesamten Bildschirmgröße in Android festgelegt?
Hier ist meine XML-Datei.
<?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>
Hier ist meine Aktivität Code
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);
}
});
Hallo, danke für die Antwort. Ich habe versucht, Ihren Code und seine Arbeit, aber ein kleines Problem können Sie mir sagen, wie Breite von AlertDialog.Builder als Füllung Eltern festlegen. – jandroid
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); \t \t \t Fenster window = dialog.getWindow(); \t \t \t lp.copyFrom (window.getAttributes()); \t \t \t lp.width = WindowManager.LayoutParams.MATCH_PARENT; \t \t \t lp.height = WindowManager.LayoutParams.WRAP_CONTENT; \t \t \t lp.gravity = Gravity.BOTTOM; \t \t \t window.setAttributes (lp); –
Danke, dass es richtig funktioniert. – jandroid