1
私は自分のアプリケーションにcamerapopup.xmlを作成しています。私はすべての画面サイズの画面の下部にこのポップアップウィンドウを表示したい。私は別のレイアウトフォルダ(レイアウト大、レイアウト小、layoutxlargeなど)を作成しようとしましたが、まったく動作しません。下のすべての画面サイズのポップアップウィンドウを設定する方法。ありがとうございました。Androidのすべての画面サイズの一番下にポップアップウィンドウを設定する方法は?
ここは私のXMLファイルです。
<?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>
はここで、私の活動コード
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);
}
});
こんにちは返事に感謝です。あなたのコードとその作業を試しましたが、AlertDialog.Builderの幅を塗りつぶしの親として設定する方法を教えてください。 – jandroid
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); \t \t \tウィンドウウィンドウ= 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); –
正しく働いてくれてありがとう。 – jandroid