80,351
社区成员
发帖
与我相关
我的任务
分享
share = (Button) findViewById(R.id.shareBtn);
share.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
//初始化一个自定义的Dialog
Dialog dialog = new ShareDialog(CartoonActivity.this, R.style.ShareDialog);
/*
* 将对话框的大小按屏幕大小的百分比设置
*/
WindowManager.LayoutParams params =dialog.getWindow().getAttributes(); // 获取对话框当前的参数值
params.height = (int) (ConstantApplication.getInstance().getScreenHeight());
params.width = (int) (ConstantApplication.getInstance().getScreenWidth());
dialog.getWindow().setAttributes(params);
dialog.show();
}
});
public class ShareDialog extends Dialog {
Context context;
public ShareDialog(Context context) {
super(context);
// TODO Auto-generated constructor stub
this.context = context;
}
public ShareDialog(Context context, int theme) {
super(context, theme);
this.context = context;
}
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
this.setContentView(R.layout.share_dialog);
}
}
<style name="ShareDialog" parent="@android:Theme.Dialog">
<item name="android:windowFrame">@null</item> <!--边框-->
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@drawable/share_dialog_bg</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowContentOverlay">@null</item>
</style>