本文整理汇总了Java中android.view.Window类的典型用法代码示例。如果您正苦于以下问题:Java Window类的具体用法?Java Window怎么用?Java Window使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Window类属于android.view包,在下文中一共展示了Window类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPreExecute
import android.view.Window; //导入依赖的package包/类
@Override
protected void onPreExecute() {
isFinalizing = true;
recordFinish = true;
runAudioThread = false;
//创建处理进度条
creatingProgress = new Dialog(FFmpegRecorderActivity.this, R.style.Dialog_loading_noDim);
Window dialogWindow = creatingProgress.getWindow();
WindowManager.LayoutParams lp = dialogWindow.getAttributes();
lp.width = (int) (getResources().getDisplayMetrics().density * 240);
lp.height = (int) (getResources().getDisplayMetrics().density * 80);
lp.gravity = Gravity.CENTER;
dialogWindow.setAttributes(lp);
creatingProgress.setCanceledOnTouchOutside(false);
creatingProgress.setContentView(R.layout.activity_recorder_progress);
progress = (TextView) creatingProgress.findViewById(R.id.recorder_progress_progresstext);
bar = (ProgressBar) creatingProgress.findViewById(R.id.recorder_progress_progressbar);
creatingProgress.show();
//txtTimer.setVisibility(View.INVISIBLE);
//handler.removeCallbacks(mUpdateTimeTask);
super.onPreExecute();
}
示例2: onPanelClosed
import android.view.Window; //导入依赖的package包/类
/**
* Default implementation of
* {@link android.view.Window.Callback#onPanelClosed(int, Menu)} for
* activities. This calls through to {@link #onOptionsMenuClosed(Menu)}
* method for the {@link android.view.Window#FEATURE_OPTIONS_PANEL} panel,
* so that subclasses of Activity don't need to deal with feature codes.
* For context menus ({@link Window#FEATURE_CONTEXT_MENU}), the
* {@link #onContextMenuClosed(Menu)} will be called.
*/
public void onPanelClosed(int featureId, Menu menu) {
switch (featureId) {
case Window.FEATURE_OPTIONS_PANEL:
mFragments.dispatchOptionsMenuClosed(menu);
onOptionsMenuClosed(menu);
break;
case Window.FEATURE_CONTEXT_MENU:
onContextMenuClosed(menu);
break;
case Window.FEATURE_ACTION_BAR:
initWindowDecorActionBar();
mActionBar.dispatchMenuVisibilityChanged(false);
break;
}
}
示例3: tintStatusBarForDrawer
import android.view.Window; //导入依赖的package包/类
/**
* Android4.4以上的状态栏着色(针对于DrawerLayout)
* 注:
* 1.如果出现界面展示不正确,删除布局中所有fitsSystemWindows属性,尤其是DrawerLayout的fitsSystemWindows属性
* 2.可以版本判断在5.0以上不调用该方法,使用系统自带
*
* @param activity Activity对象
* @param drawerLayout DrawerLayout对象
* @param statusBarColor 状态栏颜色
* @param alpha 透明栏透明度[0.0-1.0]
*/
public static void tintStatusBarForDrawer(Activity activity, DrawerLayout drawerLayout,
@ColorInt int statusBarColor,
@FloatRange(from = 0.0, to = 1.0) float alpha) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
return;
}
Window window = activity.getWindow();
ViewGroup decorView = (ViewGroup) window.getDecorView();
ViewGroup drawContent = (ViewGroup) drawerLayout.getChildAt(0);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
drawerLayout.setStatusBarBackgroundColor(statusBarColor);
int systemUiVisibility = window.getDecorView().getSystemUiVisibility();
systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
systemUiVisibility |= View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
window.getDecorView().setSystemUiVisibility(systemUiVisibility);
} else {
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
}
setStatusBar(decorView, statusBarColor, true, true);
setTranslucentView(decorView, alpha);
drawerLayout.setFitsSystemWindows(false);
drawContent.setFitsSystemWindows(true);
ViewGroup drawer = (ViewGroup) drawerLayout.getChildAt(1);
drawer.setFitsSystemWindows(false);
}
示例4: BaseDialog
import android.view.Window; //导入依赖的package包/类
public BaseDialog(Context context, int style) {
super(context, style);
this.context = context;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {//5.0 全透明实现
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.TRANSPARENT);
}
//透明状态栏
else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {//4.4全透明
getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);
}
}
示例5: onCreate
import android.view.Window; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Utils.DARK_THEME = Prefs.getBoolean("darktheme", false, this);
int theme;
String accent = Prefs.getString("accent_color", "pink_accent", this);
if (Utils.DARK_THEME) {
theme = sAccentDarkColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else {
theme = sAccentColors.get(accent);
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
}
setTheme(theme);
super.onCreate(savedInstanceState);
if (Prefs.getBoolean("forceenglish", false, this)) {
Utils.setLocale("en_US", this);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && setStatusBarColor()) {
Window window = getWindow();
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(statusBarColor());
}
}
示例6: onCreate
import android.view.Window; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
initTheme();
setContentView(R.layout.detail_layout);
//将状态栏透明
if(Build.VERSION.SDK_INT>=21){
View decorView = getWindow().getDecorView();
int option = View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN|
View.SYSTEM_UI_FLAG_LAYOUT_STABLE;
decorView.setSystemUiVisibility(option);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
init();
fillContent();
}
示例7: onCreate
import android.view.Window; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//me subscribo a las notificaciones
mFCMInteractor.subscribeToTopic("/topics/notificaciones");
//Para cuando es llamado desde una notificacion
Bundle bundle = getIntent().getExtras();
// Oculto la barra de título para que no se vea en el Splash
requestWindowFeature(Window.FEATURE_NO_TITLE);
//Establezco el contenido de la View al layout correspondiente
setContentView(R.layout.activity_splash_screen);
//Cargo las preferencias guardadas por el usuario, tipo de sesión, sesion y si es la primera vez
ControladorPreferencias.cargarPreferencias(this);
hPublicaciones = new HPublicaciones(SplashScreenActivity.this);
hPublicaciones.sethPublicaciones(hPublicaciones);
//Esto es porque vengo de una notificacion
if(bundle!=null){
hPublicaciones.setNotificacion("notificacion");
}
hPublicaciones.execute();
}
示例8: translucent
import android.view.Window; //导入依赖的package包/类
/**
* 此方法需在setContentView之前调用
*
* @param activity Activity
* @param rootView setContentView的内容
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static void translucent(Activity activity, View rootView) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
//Android4.4以下不支持沉浸式状态栏
return;
}
LogUtils.verbose("let status bar immersion");
Window window = activity.getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);//通知状态栏半透明
//使用FitsSystemWindows和ClipToPadding来避免状态栏上移,配合沉浸
rootView.setFitsSystemWindows(true);
if (rootView instanceof ViewGroup) {
((ViewGroup) rootView).setClipToPadding(true);
}
}
示例9: setMiuiStatusBarDarkMode
import android.view.Window; //导入依赖的package包/类
private static boolean setMiuiStatusBarDarkMode(Activity activity, boolean darkmode) {
Class<? extends Window> clazz = activity.getWindow().getClass();
try {
int darkModeFlag;
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
darkModeFlag = field.getInt(layoutParams);
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
extraFlagField.invoke(activity.getWindow(), darkmode ? darkModeFlag : 0, darkModeFlag);
return true;
} catch (Exception ignored) {
}
return false;
}
示例10: setStatusBarTransparent
import android.view.Window; //导入依赖的package包/类
private void setStatusBarTransparent(final boolean transparent) {
if (Build.VERSION.SDK_INT >= 21) {
final Window window = cordova.getActivity().getWindow();
if (transparent) {
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
window.setStatusBarColor(Color.TRANSPARENT);
}
else {
window.getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_VISIBLE);
}
}
}
示例11: translucentStatusBar
import android.view.Window; //导入依赖的package包/类
static void translucentStatusBar(Activity activity, boolean hideStatusBarBackground) {
Window window = activity.getWindow();
//添加Flag把状态栏设为可绘制模式
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
if (hideStatusBarBackground) {
//如果为全透明模式,取消设置Window半透明的Flag
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//设置状态栏为透明
window.setStatusBarColor(Color.TRANSPARENT);
//设置window的状态栏不可见
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
} else {
//如果为半透明模式,添加设置Window半透明的Flag
window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//设置系统状态栏处于可见状态
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_VISIBLE);
}
//view不根据系统窗口来调整自己的布局
ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
View mChildView = mContentView.getChildAt(0);
if (mChildView != null) {
ViewCompat.setFitsSystemWindows(mChildView, false);
ViewCompat.requestApplyInsets(mChildView);
}
}
示例12: onCreateDialog
import android.view.Window; //导入依赖的package包/类
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState)
{
// Idea from here
// http://thanhcs.blogspot.ru/2014/10/android-custom-dialog-fragment.html
Dialog dialog = new Dialog(mContext);
Window window = dialog.getWindow();
window.requestFeature(Window.FEATURE_NO_TITLE);
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
return dialog;
}
示例13: createExitRevealEffect
import android.view.Window; //导入依赖的package包/类
public void createExitRevealEffect(final Activity activity) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final View rootView = ((ViewGroup)activity.findViewById(Window.ID_ANDROID_CONTENT)).getChildAt(0);
Animator revealEffect = createRevealEffect(rootView, Status.EXIT);
revealEffect.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
rootView.setVisibility(View.INVISIBLE);
activity.recreate();
}
});
revealEffect.start();
} else {
activity.recreate();
}
}
示例14: darkModeForMIUI6
import android.view.Window; //导入依赖的package包/类
/**
* 设置MIUI6+的状态栏是否为darkMode,darkMode时候字体颜色及icon变黑
* http://dev.xiaomi.com/doc/p=4769/
*/
public static boolean darkModeForMIUI6(Window window, boolean darkmode) {
Class<? extends Window> clazz = window.getClass();
try {
int darkModeFlag = 0;
Class<?> layoutParams = Class.forName("android.view.MiuiWindowManager$LayoutParams");
Field field = layoutParams.getField("EXTRA_FLAG_STATUS_BAR_DARK_MODE");
darkModeFlag = field.getInt(layoutParams);
Method extraFlagField = clazz.getMethod("setExtraFlags", int.class, int.class);
extraFlagField.invoke(window, darkmode ? darkModeFlag : 0, darkModeFlag);
return true;
} catch (Exception e) {
e.printStackTrace();
return false;
}
}
示例15: onCreate
import android.view.Window; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// 隐藏标题
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.new_ad_media_play);
sensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
detector = new GestureDetector(this, new MyGesture());
initView();
initPlayHander();
initPlayInfo();
if (!isLocalPlay) {
initNetworkTimerTask();
}
videoId = getIntent().getStringExtra("videoId");
}