本文整理了Java中android.view.Window.setBackgroundDrawableResource()
方法的一些代码示例,展示了Window.setBackgroundDrawableResource()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Window.setBackgroundDrawableResource()
方法的具体详情如下:
包路径:android.view.Window
类名称:Window
方法名:setBackgroundDrawableResource
暂无
代码示例来源:origin: stackoverflow.com
@Override
public void onStart() {
super.onStart();
Window window = getDialog().getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
}
代码示例来源:origin: aa112901/remusic
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_main, container, false);
swipeRefresh = (SwipeRefreshLayout) view.findViewById(R.id.swiperefresh);
recyclerView = (RecyclerView) view.findViewById(R.id.recyclerview);
layoutManager = new LinearLayoutManager(mContext);
recyclerView.setLayoutManager(layoutManager);
//swipeRefresh.setColorSchemeResources(R.color.theme_color_PrimaryAccent);
swipeRefresh.setColorSchemeColors(ThemeUtils.getColorById(mContext, R.color.theme_color_primary));
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
reloadAdapter();
}
});
//先给adapter设置空数据,异步加载好后更新数据,防止Recyclerview no attach
mAdapter = new MainFragmentAdapter(mContext);
recyclerView.setAdapter(mAdapter);
recyclerView.setHasFixedSize(true);
recyclerView.addItemDecoration(new DividerItemDecoration(mContext, DividerItemDecoration.VERTICAL_LIST));
//设置没有item动画
((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false);
reloadAdapter();
mContext.getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
return view;
}
代码示例来源:origin: robolectric/robolectric
@Test
public void getBackgroundDrawable_returnsSetDrawable() throws Exception {
Activity activity = Robolectric.buildActivity(Activity.class).create().get();
Window window = activity.getWindow();
ShadowWindow shadowWindow = shadowOf(window);
assertThat(shadowWindow.getBackgroundDrawable()).isNull();
window.setBackgroundDrawableResource(R.drawable.btn_star);
assertThat(shadowOf(shadowWindow.getBackgroundDrawable()).createdFromResId).isEqualTo(R.drawable.btn_star);
}
代码示例来源:origin: aa112901/remusic
public void onCreate(Bundle savedInstanceState) {
splashScreen = new SplashScreen(this);
splashScreen.show(R.drawable.art_login_bg,
SplashScreen.SLIDE_LEFT);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setBackgroundDrawableResource(R.color.background_material_light_1);
barnet = (ImageView) findViewById(R.id.bar_net);
barmusic = (ImageView) findViewById(R.id.bar_music);
barfriends = (ImageView) findViewById(R.id.bar_friends);
search = (ImageView) findViewById(R.id.bar_search);
barmusic = (ImageView) findViewById(R.id.bar_music);
drawerLayout = (DrawerLayout) findViewById(R.id.fd);
mLvLeftMenu = (ListView) findViewById(R.id.id_lv_left_menu);
setToolBar();
setViewPager();
setUpDrawer();
HandlerUtil.getInstance(this).postDelayed(new Runnable() {
@Override
public void run() {
splashScreen.removeSplashScreen();
}
}, 3000);
}
代码示例来源:origin: chaychan/TouTiao
@Override
public void onOffsetChanged(AppBarLayout appBarLayout, int verticalOffset) {
//toolbar被折叠时显示状态栏
if (Math.abs(verticalOffset) > collapsingToolbarLayout.getScrimVisibleHeightTrigger()) {
if (appBarLayoutState != COLLAPSED) {
appBarLayoutState = COLLAPSED;//修改状态标记为折叠
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
activity.getWindow().setStatusBarColor(statusBarColor);
} else
setStatusBarColor(activity, statusBarColor);
}
} else {
//toolbar显示时同时显示状态栏
if (appBarLayoutState != EXPANDED) {
appBarLayoutState = EXPANDED;//修改状态标记为展开
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
}
translucentStatusBar(activity, true);
}
}
}
});
代码示例来源:origin: dkim0419/SoundRecorder
@Override
public void onStart() {
super.onStart();
//set transparent background
Window window = getDialog().getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
//disable buttons from dialog
AlertDialog alertDialog = (AlertDialog) getDialog();
alertDialog.getButton(Dialog.BUTTON_POSITIVE).setEnabled(false);
alertDialog.getButton(Dialog.BUTTON_NEGATIVE).setEnabled(false);
alertDialog.getButton(Dialog.BUTTON_NEUTRAL).setEnabled(false);
}
代码示例来源:origin: chaychan/TouTiao
public static void setStatusBarLightMode(Activity activity, int color) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
//判断是否为小米或魅族手机,如果是则将状态栏文字改为黑色
if (MIUISetStatusBarLightMode(activity, true) || FlymeSetStatusBarLightMode(activity, true)) {
//设置状态栏为指定颜色
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0
activity.getWindow().setStatusBarColor(color);
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4
//调用修改状态栏颜色的方法
setStatusBarColor(activity, color);
}
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
//如果是6.0以上将状态栏文字改为黑色,并设置状态栏颜色
activity.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
activity.getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
activity.getWindow().setStatusBarColor(color);
//fitsSystemWindow 为 false, 不预留系统栏位置.
ViewGroup mContentView = (ViewGroup) activity.getWindow().findViewById(Window.ID_ANDROID_CONTENT);
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
ViewCompat.setFitsSystemWindows(mChildView, true);
ViewCompat.requestApplyInsets(mChildView);
}
}
}
}
代码示例来源:origin: gaoyangcr7/BiometricPromptDemo
private void setupWindow(Window window) {
if (window != null) {
WindowManager.LayoutParams lp = window.getAttributes();
lp.gravity = Gravity.CENTER;
lp.dimAmount = 0;
lp.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(lp);
window.setBackgroundDrawableResource(R.color.bg_biometric_prompt_dialog);
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
}
代码示例来源:origin: gaoyangcr7/BiometricPromptDemo
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = super.onCreateDialog(savedInstanceState);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawableResource(R.color.bg_biometric_prompt_dialog);
}
return dialog;
}
代码示例来源:origin: crazyhitty/Munch
private void setActivityTheme() {
if (!SettingsPreferences.THEME) {
setTheme(R.style.DarkAppTheme_NoActionBar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(AboutActivity.this, R.color.darkColorPrimaryDark));
}
getWindow().setBackgroundDrawableResource(R.color.darkColorBackground);
}
}
代码示例来源:origin: crazyhitty/Munch
private void setActivityTheme() {
if (!SettingsPreferences.THEME) {
setTheme(R.style.DarkAppTheme_NoActionBar);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(SettingsActivity.this, R.color.darkColorPrimaryDark));
}
getWindow().setBackgroundDrawableResource(R.color.darkColorBackground);
}
}
代码示例来源:origin: crazyhitty/Munch
private void setActivityTheme() {
if (!SettingsPreferences.THEME) {
setTheme(R.style.DarkAppTheme_NoActionBar);
getWindow().setBackgroundDrawableResource(R.color.darkColorBackground);
}
}
代码示例来源:origin: fengmaolian/LoginAndShare
public void setActivity(Activity activity) {
super.setActivity(activity);
int resId = getBitmapRes(activity, "ssdk_oks_shake_to_share_back");
if (resId > 0) {
activity.setTheme(android.R.style.Theme_Dialog);
activity.requestWindowFeature(Window.FEATURE_NO_TITLE);
Window win = activity.getWindow();
win.setBackgroundDrawableResource(resId);
}
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void showProgressBarDialog() {
progress = new AlertDialog.Builder(mContext)
.setTitle(R.string.feedback_sending)
.setView(new ProgressBar(mContext))
.setCancelable(false)
.setNeutralButton(R.string.cancel, (dialogInterface, i) -> dialogInterface.cancel())
.create();
if (progress.getWindow() != null) {
progress.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background);
}
progress.show();
}
代码示例来源:origin: liying2008/SmartisanDialog
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ddh_sm_dialog_two_options);
findViews();
Window window = getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
window.setGravity(Gravity.BOTTOM);
window.setWindowAnimations(R.style.ddh_sm_BottomDialogStyle);
}
代码示例来源:origin: liying2008/SmartisanDialog
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.ddh_sm_dialog_warning);
findViews();
Window window = getWindow();
window.setBackgroundDrawableResource(android.R.color.transparent);
window.setGravity(Gravity.BOTTOM);
window.setWindowAnimations(R.style.ddh_sm_BottomDialogStyle);
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void showError(String message) {
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(getString(R.string.error))
.setMessage(message)
.setPositiveButton(R.string.ok, null)
.create();
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background);
}
dialog.show();
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void showErrorDialog(String message) {
AlertDialog dialog = new AlertDialog.Builder(this)
.setTitle(R.string.error)
.setMessage(message)
.setIcon(R.drawable.ic_error_outline)
.setPositiveButton(R.string.ok, null)
.create();
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background);
}
dialog.show();
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void displayCloseDialog() {
AlertDialog dialog = new AlertDialog.Builder(this)
.setMessage(R.string.discard_changes_question)
.setNegativeButton(R.string.discard, (dialogInterface, which) -> finish())
.setPositiveButton(R.string.keep_editing, null)
.create();
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background);
}
dialog.show();
}
代码示例来源:origin: TUM-Dev/Campus-Android
private void showLogoutDialog() {
AlertDialog dialog = new AlertDialog.Builder(mContext)
.setMessage(R.string.logout_message)
.setPositiveButton(R.string.logout, ((dialogInterface, i) -> logout()))
.setNegativeButton(R.string.cancel, null)
.create();
if (dialog.getWindow() != null) {
dialog.getWindow().setBackgroundDrawableResource(R.drawable.rounded_corners_background);
}
dialog.show();
}
内容来源于网络,如有侵权,请联系作者删除!