设计android弹出窗口
为我的应用程序创建弹出窗口时出现问题。我试图显示一个弹出窗口,填充我屏幕的总大小。问题是,我在左侧得到了1px线,但没有填充 我的弹出式xml:设计android弹出窗口,android,layout,popup,Android,Layout,Popup,为我的应用程序创建弹出窗口时出现问题。我试图显示一个弹出窗口,填充我屏幕的总大小。问题是,我在左侧得到了1px线,但没有填充 我的弹出式xml: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:id="@+id/popup" android:layout_height="match_parent"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="@+id/popup"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:background="@drawable/popup_round_corners"
android:orientation="vertical"
android:padding="5dp" >
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="5dp"
android:text="@string/zm_main_uvod" />
<Button
android:id="@+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="10dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:text="Ok" />
</LinearLayout>
</LinearLAyout>
我试着用重心,试着将偏移量设置为-30,-30,但没有发生任何事情。有什么想法吗?0个想法,我真的需要,请帮忙!我想说出现这个问题是因为
PopupWindow
使用了背景可绘制(editbox\u dropdown\u background\u dark.9.png
)。那个可画的东西的四周都是空的、透明的空间。我试着设置颜色作为背景,但没有解决办法,在左边偷了一条白线。如果你知道任何显示整个屏幕的工作样本,我非常乐意从中学习。
private void showPopup(final Activity context) {
// Inflate the popup_layout.xml
LinearLayout viewGroup = (LinearLayout)findViewById(R.id.popup);
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.startpopup, viewGroup);
// Creating the PopupWindow
final PopupWindow popup = new PopupWindow(context);
popup.setContentView(layout);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
int height=display.getHeight();
popup.setWidth(width+5);
popup.setHeight(height+5);
popup.setFocusable(true);
popup.showAtLocation(layout, Gravity.FILL, 0, 0);
Button close = (Button) layout.findViewById(R.id.close);
close.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
popup.dismiss();
}
});
}