android.view.WindowManager Java Examples

The following examples show how to use android.view.WindowManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DesktopViewerActivity.java    From AndroidDesignPreview with Apache License 2.0 8 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        // Pre-Honeycomb this is the best we can do.
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    setContentView(R.layout.main);

    mStatusTextView = (TextView) findViewById(R.id.status_text);

    mTargetView = findViewById(R.id.target);
    mTargetView.setOnTouchListener(mTouchListener);
    mTargetView.getViewTreeObserver().addOnGlobalLayoutListener(this);

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        mSystemUiHider = new SystemUiHider(mTargetView);
        mSystemUiHider.setup(getWindow());
    } else {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
}
 
Example #2
Source File: StatusBarUtil.java    From StatusBarUtil with Apache License 2.0 6 votes vote down vote up
/**
 * 设置Flyme4+的状态栏的darkMode,darkMode时候字体颜色及icon
 * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
 *
 * @param window 目标window
 * @param dark   亮色 or 暗色
 */
private static void setModeForFlyme4(Window window, boolean dark) {
    try {
        WindowManager.LayoutParams lp = window.getAttributes();
        Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
        darkFlag.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkFlag.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (dark) {
            value |= bit;
        } else {
            value &= ~bit;
        }
        meizuFlags.setInt(lp, value);
        window.setAttributes(lp);
    } catch (Exception e) {
        Log.e("StatusBar", "darkIcon: failed");
    }
}
 
Example #3
Source File: TypeSendFragment.java    From Nimingban with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyView() {
    super.onDestroyView();

    if (mPreview != null && mImagePreview != null && mEditText != null) {
        clearImagePreview();
    }

    if (mNMBRequest != null) {
        mNMBRequest.cancel();
        mNMBRequest = null;
    }

    // Hide ime keyboard
    View view = getActivity().getCurrentFocus();
    if (view != null) {
        InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(view.getWindowToken(), 0);
    }

    // Cancel FLAG_ALT_FOCUSABLE_IM
    getActivity().getWindow().clearFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
}
 
Example #4
Source File: IntroActivity.java    From juda with GNU General Public License v3.0 6 votes vote down vote up
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    addSlide(new Slide1Fragment());
    addSlide(new Slide2Fragment());
    addSlide(new Slide3Fragment());
    addSlide(new Slide4Fragment());

    showSkipButton(false);

    askForPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 3);
}
 
Example #5
Source File: JCVideoPlayer.java    From JCVideoPlayer with MIT License 6 votes vote down vote up
@Override
    public void onCompletion() {
        setUiWitStateAndScreen(CURRENT_STATE_NORMAL);
        if (textureViewContainer.getChildCount() > 0) {
            textureViewContainer.removeAllViews();
        }

        JCVideoPlayerManager.setListener(null);//这里还不完全,
//        JCVideoPlayerManager.setLastListener(null);
        JCMediaManager.instance().currentVideoWidth = 0;
        JCMediaManager.instance().currentVideoHeight = 0;

        AudioManager mAudioManager = (AudioManager) getContext().getSystemService(Context.AUDIO_SERVICE);
        mAudioManager.abandonAudioFocus(onAudioFocusChangeListener);
        JCUtils.scanForActivity(getContext()).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
        clearFullscreenLayout();
    }
 
Example #6
Source File: CaptureActivity.java    From AirFree-Client with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle icicle) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(icicle);

    Window window = getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    setContentView(R.layout.activity_capture);

    scanPreview = (SurfaceView) findViewById(R.id.capture_preview);
    scanContainer = (RelativeLayout) findViewById(R.id.capture_container);
    scanCropView = (RelativeLayout) findViewById(R.id.capture_crop_view);
    scanLine = (ImageView) findViewById(R.id.capture_scan_line);

    inactivityTimer = new InactivityTimer(this);
    beepManager = new BeepManager(this);

    TranslateAnimation animation = new TranslateAnimation(Animation.RELATIVE_TO_PARENT, 0.0f, Animation
            .RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT, 0.0f, Animation.RELATIVE_TO_PARENT,
            0.9f);
    animation.setDuration(4500);
    animation.setRepeatCount(-1);
    animation.setRepeatMode(Animation.RESTART);
    scanLine.startAnimation(animation);
}
 
Example #7
Source File: TinyCoach.java    From TinyDancer with MIT License 6 votes vote down vote up
public TinyCoach(Application context, FPSConfig config) {

        fpsConfig = config;

        //create meter view
        meterView = (TextView) LayoutInflater.from(context).inflate(R.layout.meter_view, null);

        //set initial fps value....might change...
        meterView.setText((int) fpsConfig.refreshRate + "");

        // grab window manager and add view to the window
        windowManager = (WindowManager) meterView.getContext().getSystemService(Service.WINDOW_SERVICE);

        int minWidth = meterView.getLineHeight()
                + meterView.getTotalPaddingTop()
                + meterView.getTotalPaddingBottom()
                + (int) meterView.getPaint().getFontMetrics().bottom;
        meterView.setMinWidth(minWidth);

        addViewToWindow(meterView);
    }
 
Example #8
Source File: MainActivity.java    From BottomNavigationBar with Apache License 2.0 6 votes vote down vote up
private boolean hasSystemNavigationBar() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        Display d = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();

        DisplayMetrics realDisplayMetrics = new DisplayMetrics();
        d.getRealMetrics(realDisplayMetrics);

        int realHeight = realDisplayMetrics.heightPixels;
        int realWidth = realDisplayMetrics.widthPixels;

        DisplayMetrics displayMetrics = new DisplayMetrics();
        d.getMetrics(displayMetrics);

        int displayHeight = displayMetrics.heightPixels;
        int displayWidth = displayMetrics.widthPixels;

        return (realWidth - displayWidth) > 0 || (realHeight - displayHeight) > 0;
    } else {
        boolean hasMenuKey = ViewConfiguration.get(this).hasPermanentMenuKey();
        boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
        return !hasMenuKey && !hasBackKey;
    }
}
 
Example #9
Source File: Engine.java    From 30-android-libraries-in-30-days with Apache License 2.0 6 votes vote down vote up
/**
 * @return <code>true</code> when the sensor was successfully enabled, <code>false</code> otherwise.
 */
public boolean enableAccelerationSensor(final Context pContext, final IAccelerationListener pAccelerationListener, final AccelerationSensorOptions pAccelerationSensorOptions) {
	final SensorManager sensorManager = (SensorManager) pContext.getSystemService(Context.SENSOR_SERVICE);
	if(Engine.isSensorSupported(sensorManager, Sensor.TYPE_ACCELEROMETER)) {
		this.mAccelerationListener = pAccelerationListener;

		if(this.mAccelerationData == null) {
			final Display display = ((WindowManager) pContext.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
			final int displayRotation = display.getOrientation();
			this.mAccelerationData = new AccelerationData(displayRotation);
		}

		this.registerSelfAsSensorListener(sensorManager, Sensor.TYPE_ACCELEROMETER, pAccelerationSensorOptions.getSensorDelay());

		return true;
	} else {
		return false;
	}
}
 
Example #10
Source File: NativePageDialog.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    FrameLayout view = (FrameLayout) LayoutInflater.from(getContext()).inflate(
            R.layout.dialog_with_titlebar, null);
    view.addView(mPage.getView(), 0);
    setContentView(view);

    getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);

    TextView title = (TextView) view.findViewById(R.id.title);
    title.setText(mPage.getTitle());

    ImageButton closeButton = (ImageButton) view.findViewById(R.id.close_button);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            dismiss();
        }
    });
}
 
Example #11
Source File: SystemUiVisibilityUtil.java    From LeisureRead with Apache License 2.0 6 votes vote down vote up
/**
 * * 显示或隐藏StatusBar
 *
 * @param enable false 显示,true 隐藏
 */
public static void hideStatusBar(Window window, boolean enable) {

  WindowManager.LayoutParams p = window.getAttributes();
  if (enable)
  //|=:或等于,取其一
  {
    p.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
  } else
  //&=:与等于,取其二同时满足,     ~ : 取反
  {
    p.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
  }

  window.setAttributes(p);
  window.addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
}
 
Example #12
Source File: AppBaseActivity.java    From browser with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	//PushAgent.getInstance(this).onAppStart();
	MobclickAgent.openActivityDurationTrack(false);

	getWindow().setSoftInputMode(
			WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN
	);
	mBaseActivity.init(getBaseContext(), this);
	onActivityInit();
	LogUtil.d(TAG, "checktask onCreate:" + super.getClass().getSimpleName()
			+ "#0x" + super.hashCode() + ", taskid:" + getTaskId()
			+ ", task:" + new ActivityTaskUtils(this));
	abstracrRegist();
	getTopBarView().showSearch(hasSearch());

}
 
Example #13
Source File: HiddenCameraService.java    From android-hidden-camera with Apache License 2.0 6 votes vote down vote up
/**
 * Add camera preview to the root of the activity layout.
 *
 * @return {@link CameraPreview} that was added to the view.
 */
private CameraPreview addPreView() {
    //create fake camera view
    CameraPreview cameraSourceCameraPreview = new CameraPreview(this, this);
    cameraSourceCameraPreview.setLayoutParams(new ViewGroup
            .LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

    mWindowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    WindowManager.LayoutParams params = new WindowManager.LayoutParams(1, 1,
            Build.VERSION.SDK_INT < Build.VERSION_CODES.O ?
                    WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY :
                    WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY,
            WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH,
            PixelFormat.TRANSLUCENT);

    mWindowManager.addView(cameraSourceCameraPreview, params);
    return cameraSourceCameraPreview;
}
 
Example #14
Source File: ActivityRatingBar.java    From iGap-Android with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {

    G.isShowRatingDialog = true;

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_rating_bar);

    id = getIntent().getExtras().getLong(ID_EXTRA);

    initComponent();
}
 
Example #15
Source File: DisplayUtils.java    From WanAndroid with MIT License 6 votes vote down vote up
public static int getDpi(Context context){
    int dpi = 0;
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = windowManager.getDefaultDisplay();
    DisplayMetrics displayMetrics = new DisplayMetrics();
    @SuppressWarnings("rawtypes")
    Class c;
    try {
        c = Class.forName("android.view.Display");
        @SuppressWarnings("unchecked")
        Method method = c.getMethod("getRealMetrics",DisplayMetrics.class);
        method.invoke(display, displayMetrics);
        dpi=displayMetrics.heightPixels;
    }catch(Exception e){
        e.printStackTrace();
    }
    return dpi;
}
 
Example #16
Source File: CarlProgressbar.java    From YCProgress with Apache License 2.0 6 votes vote down vote up
private void initView(Context context) {
    mWindowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    mLayoutParams = new WindowManager.LayoutParams();
    mLayoutParams.gravity = Gravity.START | Gravity.TOP;
    mLayoutParams.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLayoutParams.height = ViewGroup.LayoutParams.WRAP_CONTENT;
    mLayoutParams.format = PixelFormat.TRANSLUCENT;
    mLayoutParams.flags = WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
            | WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N_MR1) {
        mLayoutParams.type = WindowManager.LayoutParams.TYPE_APPLICATION;
    } else {
        mLayoutParams.type = WindowManager.LayoutParams.TYPE_TOAST;
    }
}
 
Example #17
Source File: UserTextDialog.java    From Android-Application-ZJB with Apache License 2.0 6 votes vote down vote up
/**
 * 初始化
 */
private void init() {
    // 弹出自定义dialog
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View view = inflater.inflate(R.layout.dlg_user_text, null);

    // 对话框
    getWindow().setBackgroundDrawable(new ColorDrawable(0));
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // 设置宽度为屏幕的宽度
    WindowManager.LayoutParams lp = getWindow().getAttributes();
    lp.width = 666; // 设置宽度
    getWindow().setAttributes(lp);
    getWindow().setContentView(view);
    setCancelable(false);
    ButterKnife.inject(this);
}
 
Example #18
Source File: InsightAlertActivity.java    From AndroidAPS with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_insight_alert);

    bindService(new Intent(this, InsightAlertService.class), serviceConnection, BIND_AUTO_CREATE);

    icon = findViewById(R.id.icon);
    errorCode = findViewById(R.id.error_code);
    errorTitle = findViewById(R.id.error_title);
    errorDescription = findViewById(R.id.error_description);
    mute = findViewById(R.id.mute);
    confirm = findViewById(R.id.confirm);

    setFinishOnTouchOutside(false);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
            | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD
            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
            | WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
}
 
Example #19
Source File: Eyes.java    From MeiBaseModule with Apache License 2.0 6 votes vote down vote up
/**
 * 设置状态栏图标为深色和魅族特定的文字风格,Flyme4.0以上
 */
static boolean FlymeSetStatusBarLightMode(Activity activity, boolean darkmode) {
    boolean result = false;
    try {
        WindowManager.LayoutParams lp = activity.getWindow().getAttributes();
        Field darkFlag = WindowManager.LayoutParams.class
                .getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
        Field meizuFlags = WindowManager.LayoutParams.class
                .getDeclaredField("meizuFlags");
        darkFlag.setAccessible(true);
        meizuFlags.setAccessible(true);
        int bit = darkFlag.getInt(null);
        int value = meizuFlags.getInt(lp);
        if (darkmode) {
            value |= bit;
        } else {
            value &= ~bit;
        }
        meizuFlags.setInt(lp, value);
        activity.getWindow().setAttributes(lp);
        result = true;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return result;
}
 
Example #20
Source File: UIStatusBarController.java    From FastAndroid with Apache License 2.0 6 votes vote down vote up
/**
 * OPPOAndroid系统
 * https://open.oppomobile.com/wiki/index#id=73494
 */
public static void setStatusBarOppo(@NonNull Activity activity, boolean lightMode) {
    int SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT = 0x00000010;
    Window window = activity.getWindow();
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.getDecorView().setSystemUiVisibility(SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT);

    int vis = window.getDecorView().getSystemUiVisibility();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        if (lightMode) {
            vis |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        } else {
            vis &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR;
        }
    } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        if (lightMode) {
            vis |= SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
        } else {
            vis &= ~SYSTEM_UI_FLAG_OP_STATUS_BAR_TINT;
        }
    }
    window.getDecorView().setSystemUiVisibility(vis);
}
 
Example #21
Source File: AdjustStatusbar.java    From BaseAndroidApp with Apache License 2.0 6 votes vote down vote up
@TargetApi (Build.VERSION_CODES.KITKAT)
public static void addColorAndHeight(@NonNull Activity activity) {
   if (!activity.getResources()
         .getBoolean(R.bool.should_color_status_bar)) {
      return;
   }
   View statusBar = activity.findViewById(R.id.statusBarBackground);
   if (statusBar == null) {
      return;
   }
   Window window = activity.getWindow();
   window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS,
         WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
   int statusBarHeight = getStatusBarHeight(activity);
   if (statusBarHeight != 0) {
      final int color = ContextCompat.getColor(activity, R.color.primary_dark);
      statusBar.getLayoutParams().height = +statusBarHeight;
      statusBar.setBackgroundColor(color);
      statusBar.setVisibility(View.VISIBLE);
   } else {
      statusBar.setVisibility(View.GONE);
   }
}
 
Example #22
Source File: SystemBarUtils.java    From MarkdownEditors with Apache License 2.0 5 votes vote down vote up
/**
 * 设置Flyme4+的darkMode,darkMode时候字体颜色及icon变黑
 * http://open-wiki.flyme.cn/index.php?title=Flyme%E7%B3%BB%E7%BB%9FAPI
 */
public static boolean setStatusBarDarkModeForFlyme4(Window window, boolean dark) {
    boolean result = false;
    if (window != null) {
        try {
            WindowManager.LayoutParams e = window.getAttributes();
            Field darkFlag = WindowManager.LayoutParams.class.getDeclaredField("MEIZU_FLAG_DARK_STATUS_BAR_ICON");
            Field meizuFlags = WindowManager.LayoutParams.class.getDeclaredField("meizuFlags");
            darkFlag.setAccessible(true);
            meizuFlags.setAccessible(true);
            int bit = darkFlag.getInt(null);
            int value = meizuFlags.getInt(e);
            if (dark) {
                value |= bit;
            } else {
                value &= ~bit;
            }

            meizuFlags.setInt(e, value);
            window.setAttributes(e);
            result = true;
        } catch (Exception var8) {
            Log.e("StatusBar", "setStatusBarDarkIcon: failed");
        }
    }

    return result;
}
 
Example #23
Source File: FlexibleUtils.java    From FlexibleAdapter with Apache License 2.0 5 votes vote down vote up
@NonNull
public static Point getScreenDimensions(Context context) {
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();

    DisplayMetrics dm = new DisplayMetrics();
    display.getMetrics(dm);

    Point point = new Point();
    point.set(dm.widthPixels, dm.heightPixels);
    return point;
}
 
Example #24
Source File: WizardPage1Activity.java    From secure-quick-reliable-login with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Utils.setLanguage(this);

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);

    setContentView(R.layout.startup_wizard_page_1);

    TextView secureText = findViewById(R.id.wizard_secure);
    Spannable secureSpan = new SpannableString("Secure");
    secureSpan.setSpan(new ForegroundColorSpan(Color.YELLOW), 1, 6, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    secureText.setText(secureSpan);

    TextView quickText = findViewById(R.id.wizard_quick);
    Spannable quickSpan = new SpannableString("Quick");
    quickSpan.setSpan(new ForegroundColorSpan(Color.YELLOW), 1, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    quickText.setText(quickSpan);

    TextView reliableText = findViewById(R.id.wizard_reliable);
    Spannable reliableSpan = new SpannableString("Reliable");
    reliableSpan.setSpan(new ForegroundColorSpan(Color.YELLOW), 1, 8, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    reliableText.setText(reliableSpan);

    TextView loginText = findViewById(R.id.wizard_login);
    Spannable loginSpan = new SpannableString("Login");
    loginSpan.setSpan(new ForegroundColorSpan(Color.YELLOW), 1, 5, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    loginText.setText(loginSpan);

    Button next = findViewById(R.id.wizard_next);
    next.setOnClickListener((a) -> {
        startActivity(new Intent(this, WizardPage2Activity.class));
    });
    Button skip = findViewById(R.id.wizard_skip);
    skip.setOnClickListener((a) -> {
        startActivity(new Intent(this, StartActivity.class));
    });
}
 
Example #25
Source File: StatusBarUtil.java    From TextBannerView with Apache License 2.0 5 votes vote down vote up
/** 设置状态栏darkMode,字体颜色及icon变黑(目前支持MIUI6以上,Flyme4以上,Android M以上) */
    public static void darkMode(Window window, int color, @FloatRange(from = 0.0, to = 1.0) float alpha) {
        if (isFlyme4Later()) {
            darkModeForFlyme4(window, true);
            immersive(window,color,alpha);
        } else if (isMIUI6Later()) {
            darkModeForMIUI6(window, true);
            immersive(window,color,alpha);
        } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            darkModeForM(window, true);
            immersive(window, color, alpha);
        } else if (Build.VERSION.SDK_INT >= 19) {
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            setTranslucentView((ViewGroup) window.getDecorView(), color, alpha);
        } else {
            immersive(window, color, alpha);
        }
//        if (Build.VERSION.SDK_INT >= 21) {
//            window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//            window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
//            window.setStatusBarColor(Color.TRANSPARENT);
//        } else if (Build.VERSION.SDK_INT >= 19) {
//            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
//        }

//        setTranslucentView((ViewGroup) window.getDecorView(), color, alpha);
    }
 
Example #26
Source File: ScreenUtils.java    From MaterialHome with Apache License 2.0 5 votes vote down vote up
/**
 * 获得屏幕宽度
 *
 * @param context
 * @return
 */
public static int getScreenHeight(Context context) {
    WindowManager wm = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    DisplayMetrics outMetrics = new DisplayMetrics();
    wm.getDefaultDisplay().getMetrics(outMetrics);
    return outMetrics.heightPixels;
}
 
Example #27
Source File: MdCompat.java    From android-md-core with Apache License 2.0 5 votes vote down vote up
public static void enableTranslucentStatus(Activity activity) {
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
    Window window = activity.getWindow();
    window.setFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS, WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
    window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    window.setStatusBarColor(Color.TRANSPARENT);
  }
}
 
Example #28
Source File: URotateLayout.java    From UCDMediaPlayer_Android with MIT License 5 votes vote down vote up
public void updateScreenWidthAndHeight() {
    Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
    DisplayMetrics metrics = new DisplayMetrics();
    display.getMetrics(metrics);
    screenWidth = metrics.widthPixels;
    screenHeight = metrics.heightPixels;
}
 
Example #29
Source File: DisplayUtil.java    From demo4Fish with MIT License 5 votes vote down vote up
/**
 * 获取屏幕宽度
 *
 * @param context
 * @return
 */
public static int getScreenWidth(Context context) {
    WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Point point = new Point();
    windowManager.getDefaultDisplay().getSize(point);
    return point.x;
}
 
Example #30
Source File: RegistActivity.java    From weixin with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
	super.onCreate(savedInstanceState);
	setContentView(R.layout.cgt_activity_regist);
	//显示软体键盘
	getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
	init();
}