Я создал всплывающее окно с использованием файла макета 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 (layout, ... 'so' layout' является ** содержимым и родителем в то же время ** ... увлекательный – Selvin
@Selvin: Что мне делать? – Barrier