大家好,我正在制作一个应用程序,在其中显示带有背景图像的弹出窗口,
我为弹出窗口设置的背景图像是透明图像,但问题是显示弹出窗口时背景图像无法正确显示....
虽然它是透明图像,但它会在图像的角落显示黑色条带..
有人可以帮帮我吗?
PopupDemoActivity.java
包 com.demo.popupwindow.;
import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.PopupWindow;
public class PopupDemoActivity extends Activity {
Button searchMenu, viewOrder;
PopupWindow popUp;
LayoutParams params;
FrameLayout layout;
// LinearLayout layout;
boolean click = true;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.popdemodemo);
searchMenu = (Button) findViewById(R.id.menu);
viewOrder = (Button) findViewById(R.id.order);
popUp = new PopupWindow(this);
// layout = new LinearLayout(this);
layout = new FrameLayout(this);
viewOrder.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (click) {
popUp.showAtLocation(layout, Gravity.TOP | Gravity.RIGHT,
0, 0);
popUp.update(30, 75, 500, 400);
click = false;
} else {
popUp.dismiss();
click = true;
}
}
});
// popUp.setContentView(layout);
params = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
layout.setBackgroundResource(R.drawable.order_back);
// layout.setBackgroundColor(Color.TRANSPARENT);
popUp.setContentView(layout);
}
}
弹出演示.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white_color"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/header_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center" >
<Button
android:id="@+id/menu"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:text="Search Menu"
android:textColor="@color/white_color"
android:textSize="25sp"
android:textStyle="bold" />
<Button
android:id="@+id/order"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="30dp"
android:text="View Order"
android:textColor="@color/white_color"
android:textSize="25sp"
android:textStyle="bold" />
</RelativeLayout>