现在的位置: 首页 > 综合 > 正文

android PopupWindow demo

2017年10月14日 ⁄ 综合 ⁄ 共 636字 ⁄ 字号 评论关闭

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);
    }
}

抱歉!评论已关闭.