cách hiển thị cửa sổ bật lên có hình nền trong suốt?
Hello guys, tôi đang làm cho một ứng dụng, trong đó tôi hiển thị cửa sổ pop up-cửa sổ với hình nền,
hình nền i đặt cho cửa sổ popup là trong suốt hình ảnh nhưng vấn đề là khi các cửa sổ popup sẽ được hiển thị hình nền không được hiển thị đúng cách ....
mặc dù nó là một hình ảnh trong suốt nó sẽ hiển thị dải màu đen xung quanh các góc của hình ảnh ..
ai có thể giúp tôi ra ??
PopupDemoActivity.java
gói 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);
}
}
popupdemo.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>
bài viết của bạn tập tin bố trí xem popup của bạn xin vui lòng. – Wenhui