public class PopupwindowActivity extends Activity {
LinearLayout ll;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ll = (LinearLayout) findViewById(R.id.container);
}
public void click(View view){
TextView tv = new TextView(this);
tv.setTextSize(20);
tv.setText("哥是彈出窗體");
tv.setTextColor(Color.RED);
//PopupWindow popupWindow = new PopupWindow(tv, 100, 100);
PopupWindow popupWindow = new PopupWindow(tv, 100, 100, true);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.showAtLocation(ll, Gravity.LEFT | Gravity.TOP, 50,100);
}
}