-1
xmlレイアウトファイルを使用してポップアップウィンドウを作成しました。ボタンをクリックしたときの指示を表示するために使用しました。Android:作成されたポップアップウィンドウがデバイスに明瞭に表示されない
これは私が分離できなかった、
popup_window.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/popup_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView1"
android:layout_marginTop="50dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:text="Theme"
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView2"
android:layout_marginTop="24dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:text="Full"
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView3"
android:layout_marginTop="24dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:text="@string/full_detail"
android:textSize="16sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView4"
android:layout_marginTop="48dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:text="Lite"
android:textSize="20sp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView5"
android:layout_marginTop="24dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:text="@string/lite_detail"
android:textSize="16sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="40dp"
android:layout_gravity="right">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView6"
android:textSize="20sp"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView7"
android:text="Cancel"
android:layout_marginLeft="40dp"
android:clickable="true"
android:textSize="20sp"
android:layout_weight="1"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/pop_txtView8"
android:text="OK"
android:layout_marginLeft="10dp"
android:clickable="true"
android:textSize="20sp"
android:layout_weight="1"/>
</LinearLayout>
</LinearLayout>
そして、これは私がポップアップウィンドウに呼ばれる方法である、
private PopupWindow popupWindow;
@InjectView(R.id.ib_question)
ImageButton qestionImageButton;
@OnClick(R.id.ib_question)
public void showPopup(){
try{
LayoutInflater inflater = (LayoutInflater) ProfileUserActivity.this
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(R.layout.popup_window,
(ViewGroup) findViewById(R.id.popup_layout));
popupWindow = new PopupWindow(layout, 300, 370, true);
popupWindow.showAtLocation(layout, Gravity.CENTER, 0, 0);
}catch (Exception ex){
ex.printStackTrace();
}
}
私のポップアップウィンドウのコードですこの画像ボタンをクリックしたときのポップアップウィンドウとアクティビティ
以下のスクリーンショットは、私の問題についての明確なアイデアです。
このことについてどんな考えをお持ちですか?
'popupWindow =新しいPopupWindow(レイアウト、...)のように設定する必要があります。 popupWindow.showAtLocation(レイアウト、... 'だから'レイアウトは**コンテンツと同時に親です** ...魅惑的です – Selvin
@セルビン:どうすればいいですか? – Barrier