本文整理汇总了Java中android.view.Window.setBackgroundDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java Window.setBackgroundDrawable方法的具体用法?Java Window.setBackgroundDrawable怎么用?Java Window.setBackgroundDrawable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.Window
的用法示例。
在下文中一共展示了Window.setBackgroundDrawable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: beginCameraDialog
import android.view.Window; //导入方法依赖的package包/类
final void beginCameraDialog() {
DIALOG.show();
final Window window = DIALOG.getWindow();
if (window != null) {
window.setContentView(R.layout.dialog_camera_panel);
window.setGravity(Gravity.BOTTOM);
window.setWindowAnimations(R.style.anim_panel_up_from_bottom);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//设置属性
final WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(params);
window.findViewById(R.id.photodialog_btn_cancel).setOnClickListener(this);
window.findViewById(R.id.photodialog_btn_take).setOnClickListener(this);
window.findViewById(R.id.photodialog_btn_native).setOnClickListener(this);
}
}
示例2: initDialog
import android.view.Window; //导入方法依赖的package包/类
private void initDialog() {
contentLayout = new FrameLayout(activity);
contentLayout.setLayoutParams(new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
contentLayout.setFocusable(true);
contentLayout.setFocusableInTouchMode(true);
dialog = new Dialog(activity);
dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
dialog.setCancelable(true);//按返回键取消窗体
dialog.setOnKeyListener(this);
dialog.setOnDismissListener(this);
Window window = dialog.getWindow();
if (window != null) {
window.setGravity(Gravity.BOTTOM);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//AndroidRuntimeException: requestFeature() must be called before adding content
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setContentView(contentLayout);
}
setSize(screenWidthPixels, WRAP_CONTENT);
}
示例3: onActivityCreate
import android.view.Window; //导入方法依赖的package包/类
public void onActivityCreate() {
Window window = mActivity.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.getDecorView().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
mSwipeBackLayout = new SwipeBackLayout(mActivity);
mSwipeBackLayout.addSwipeListener(new SwipeBackLayout.SwipeListener() {
@Override
public void onScrollStateChange(int state, float scrollPercent) {
}
@Override
public void onEdgeTouch(int edgeFlag) {
Utils.convertActivityToTranslucent(mActivity);
}
@Override
public void onScrollOverThreshold() {
}
});
}
示例4: onStart
import android.view.Window; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
if (window != null) {
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM;
params.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
}
示例5: onCreateView
import android.view.Window; //导入方法依赖的package包/类
/**
* 使用 onCreateView 创建 对话框的样式 使用自定义视图
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
getDialog().getWindow().setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
/**
* 先设置 无标题样式的 对话框
*/
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
final Window window = getDialog().getWindow();
View view = inflater.inflate(R.layout.dialog_webview_fragment, ((ViewGroup) window.findViewById(android.R.id.content)), false);//需要用android.R.id.content这个view
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));//注意此处
window.setLayout(-1, -2);//这2行,和上面的一样,注意顺序就行;
webView = view.findViewById(R.id.webView);
RelativeLayout azkRefreshLayout = view.findViewById(R.id.root_view);
azkRefreshLayout.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismissAllowingStateLoss();
}
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// http://blog.csdn.net/zhulin2609/article/details/51437821 基于webkit核心的webview端调试
setWebContentsDebuggingEnabled(true);
}
initWebSettings(webView);
getDialog().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager
.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
webView.loadUrl(Constant.ZKTEAM_XIAN_LIAO_ME_URL);
return view;
}
示例6: init
import android.view.Window; //导入方法依赖的package包/类
private void init(Context context) {
contentLayout = new FrameLayout(context);
contentLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
contentLayout.setFocusable(true);
contentLayout.setFocusableInTouchMode(true);
dialog = new android.app.Dialog(context);
dialog.setCanceledOnTouchOutside(true);//触摸屏幕取消窗体
dialog.setCancelable(true);//按返回键取消窗体
Window window = dialog.getWindow();
window.setGravity(Gravity.BOTTOM);//位于屏幕底部
window.setWindowAnimations(R.style.Animation_Popup);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//android.util.AndroidRuntimeException: requestFeature() must be called before adding content
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setContentView(contentLayout);
}
示例7: initView
import android.view.Window; //导入方法依赖的package包/类
protected void initView() {
Window window = getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.getDecorView().setBackgroundDrawable(null);
setContentView(R.layout.sql_base_activity_layout);
mContext = this;
FrameLayout frameLayout = (FrameLayout) findViewById(R.id.fragment);
if( frameLayout != null){
frameLayout.addView(LayoutInflater.from(mContext).inflate(setViews(),null));
}
initIntent(getIntent());
findViews();
initToolBar();
initFloatBtn();
}
示例8: onCreateDialog
import android.view.Window; //导入方法依赖的package包/类
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.setCancelable(false);
setCancelable(false);
Window window = dialog.getWindow();
if (window != null) {
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
window.setDimAmount(0);
}
return dialog;
}
示例9: onStart
import android.view.Window; //导入方法依赖的package包/类
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
WindowManager.LayoutParams params = window.getAttributes();
params.gravity = Gravity.BOTTOM;
params.width = WindowManager.LayoutParams.MATCH_PARENT;
window.setAttributes(params);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
示例10: buildCenterSheet
import android.view.Window; //导入方法依赖的package包/类
protected BuildBean buildCenterSheet(BuildBean bean) {
AlertDialog.Builder builder = new AlertDialog.Builder(bean.mContext);
SheetHolder holder = new SheetHolder(bean.mContext);
builder.setView(holder.rootView);
AlertDialog dialog = builder.create();
bean.alertDialog = dialog;
if (bean.isVertical && !TextUtils.isEmpty(bean.bottomTxt)) {
Window window = dialog.getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
}
holder.assingDatasAndEvents(bean.mContext, bean);
return bean;
}
示例11: onCreateDialog
import android.view.Window; //导入方法依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
Window window = dialog.getWindow();
if (window == null) {
Log.wtf(TAG, "getWindow() should not be null ever");
return dialog;
}
window.getAttributes().windowAnimations = R.style.coach_mark_dialog_animation;
window.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(getContext(),
R.color.coach_mark_transparent_color)));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
示例12: onCreateView
import android.view.Window; //导入方法依赖的package包/类
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return createLayout();
}
示例13: beginCameraDialog
import android.view.Window; //导入方法依赖的package包/类
/**
* 开启选择拍照还是从相册取照片的对话框
*/
final void beginCameraDialog(){
DIALOG.show();
//获取window,方便设置属性
final Window window = DIALOG.getWindow();
if(window != null){
//设置dialog的自定义布局
window.setContentView(R.layout.dialog_camera_panel);
//设置dialog在底部
window.setGravity(Gravity.BOTTOM);
//设置动画
window.setWindowAnimations(R.style.anim_panel_up_from_bottom);
//设置透明背景
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
//获取属性
final WindowManager.LayoutParams params = window.getAttributes();
//宽度
params.width = WindowManager.LayoutParams.MATCH_PARENT;
//弹出对话框背景为灰色
params.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
params.dimAmount = 0.5f;
window.setAttributes(params);
//设置按钮点击事件
window.findViewById(R.id.btn_dialog_cancel).setOnClickListener(this);
window.findViewById(R.id.btn_dialog_take_photo).setOnClickListener(this);
window.findViewById(R.id.btn_dialog_pick_photo).setOnClickListener(this);
}
}
示例14: setLayout
import android.view.Window; //导入方法依赖的package包/类
private void setLayout() {
Window window = getDialog().getWindow();
window.setBackgroundDrawable(new ColorDrawable(0));
window.getDecorView().setPadding(0, 0, 0, 0);
window.setGravity(Gravity.BOTTOM);
// window.setWindowAnimations(R.style.AnimBottom);
WindowManager.LayoutParams lp = window.getAttributes();
lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
lp.height = ViewGroup.LayoutParams.WRAP_CONTENT;
lp.dimAmount = 0;
window.setAttributes(lp);
}
示例15: showDialogForView
import android.view.Window; //导入方法依赖的package包/类
private void showDialogForView(View view) {
mDialog = new Dialog(mActivity) {
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (!hasFocus) super.dismiss();
}
};
mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
mDialog.setCanceledOnTouchOutside(true);
mDialog.addContentView(view,
new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT));
mDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
mItemSelectedCallback.onItemSelected("");
}
});
Window window = mDialog.getWindow();
if (!DeviceFormFactor.isTablet(mActivity)) {
// On smaller screens, make the dialog fill the width of the screen,
// and appear at the top.
window.setBackgroundDrawable(new ColorDrawable(Color.WHITE));
window.setGravity(Gravity.TOP);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT);
}
mDialog.show();
}