Java Code Examples for android.support.v7.app.AppCompatActivity#getWindowManager()

The following examples show how to use android.support.v7.app.AppCompatActivity#getWindowManager() . 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: ScreenUtil.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
public static int getDisplayWidth(AppCompatActivity activity){
    int width=0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        width = point.x;
    }
    return width;
}
 
Example 2
Source File: ScreenUtil.java    From incubator-weex-playground with Apache License 2.0 5 votes vote down vote up
public static int getDisplayHeight(AppCompatActivity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity.getSupportActionBar() != null) {
      int actionbar= activity.getSupportActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}
 
Example 3
Source File: ScreenUtil.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
public static int getDisplayWidth(AppCompatActivity activity){
    int width=0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        width = point.x;
    }
    return width;
}
 
Example 4
Source File: ScreenUtil.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 5 votes vote down vote up
public static int getDisplayHeight(AppCompatActivity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity.getSupportActionBar() != null) {
      int actionbar= activity.getSupportActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}
 
Example 5
Source File: ScreenUtil.java    From WeexOne with MIT License 5 votes vote down vote up
public static int getDisplayWidth(AppCompatActivity activity){
    int width=0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        width = point.x;
    }
    return width;
}
 
Example 6
Source File: ScreenUtil.java    From WeexOne with MIT License 5 votes vote down vote up
public static int getDisplayHeight(AppCompatActivity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity != null && activity.getSupportActionBar() != null) {
      int actionbar= activity.getSupportActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}
 
Example 7
Source File: ScreenUtil.java    From weex with Apache License 2.0 5 votes vote down vote up
public static int getDisplayWidth(AppCompatActivity activity){
    int width=0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        width = point.x;
    }
    return width;
}
 
Example 8
Source File: ScreenUtil.java    From weex with Apache License 2.0 5 votes vote down vote up
public static int getDisplayHeight(AppCompatActivity activity) {
    int height = 0;
    if (activity != null && activity.getWindowManager() != null && activity.getWindowManager().getDefaultDisplay() != null) {
        Point point=new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(point);
        height=point.y;
    }

    Log.e(TAG, "isSupportSmartBar:" + isSupportSmartBar);

    if (isSupportSmartBar) {
        int smartBarHeight = getSmartBarHeight(activity);
        Log.e(TAG, "smartBarHeight:" + smartBarHeight);
        height -= smartBarHeight;
    }

    if (activity.getSupportActionBar() != null) {
      int actionbar= activity.getSupportActionBar().getHeight();
      if(actionbar==0){
        TypedArray actionbarSizeTypedArray=activity.obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        actionbar= (int) actionbarSizeTypedArray.getDimension(0,0);
      }
      Log.d(TAG, "actionbar:" + actionbar);
      height -= actionbar;
    }

    int status = getStatusBarHeight(activity);
    Log.d(TAG, "status:" + status);

    height -= status;

    Log.d(TAG,"height:"+height);
    return height;
}