当前位置: 首页>>代码示例>>Java>>正文


Java Activity.obtainStyledAttributes方法代码示例

本文整理汇总了Java中android.app.Activity.obtainStyledAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.obtainStyledAttributes方法的具体用法?Java Activity.obtainStyledAttributes怎么用?Java Activity.obtainStyledAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.obtainStyledAttributes方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDisplayHeight

import android.app.Activity; //导入方法依赖的package包/类
public static int getDisplayHeight(Activity 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.getActionBar() != null) {
      int actionbar= activity.getActionBar().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;
}
 
开发者ID:osmartian,项目名称:martian-cli,代码行数:35,代码来源:CommonUtils.java

示例2: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:forplane,项目名称:head,代码行数:52,代码来源:SystemBarTintManager.java

示例3: updateDropboxLinkUnlinkButton

import android.app.Activity; //导入方法依赖的package包/类
public void updateDropboxLinkUnlinkButton() {
    if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG);

    Activity activity = getActivity();

    if (mListener != null && activity != null) {
        TypedArray typedArray = activity.obtainStyledAttributes(R.styleable.Icons);

        String text;
        int imageResource;

        if (mListener.isDropboxLinked()) {
            text = getString(R.string.repo_dropbox_button_linked);
            imageResource = typedArray.getResourceId(R.styleable.Icons_oic_dropbox_linked, 0);
        } else {
            text = getString(R.string.repo_dropbox_button_not_linked);
            imageResource = typedArray.getResourceId(R.styleable.Icons_oic_dropbox_not_linked, 0);
        }

        typedArray.recycle();

        mDropboxLinkUnlinkButton.setText(text);

        if (imageResource != 0) {
            mDropboxIcon.setImageResource(imageResource);
        }
    }
}
 
开发者ID:orgzly,项目名称:orgzly-android,代码行数:29,代码来源:DropboxRepoFragment.java

示例4: getActionBarHeight

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 计算actionbar高度
 *
 * @param activity Activity
 * @return actionbar高度
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static float getActionBarHeight(Activity activity) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        TypedArray actionbarSizeTypedArray = activity
                .obtainStyledAttributes(new int[]{android.R.attr.actionBarSize});
        float a = actionbarSizeTypedArray.getDimension(0, 0);
        actionbarSizeTypedArray.recycle();
        return a;
    }
    return 0;
}
 
开发者ID:Pingsh,项目名称:Mix,代码行数:18,代码来源:SystemUtil.java

示例5: getThemeUpIndicator

import android.app.Activity; //导入方法依赖的package包/类
public static Drawable getThemeUpIndicator(Object info, Activity activity) {
    final TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
    final Drawable result = a.getDrawable(0);
    a.recycle();
    return result;
}
 
开发者ID:ultrasonic,项目名称:ultrasonic,代码行数:7,代码来源:ActionBarHelperNative.java

示例6: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@SuppressLint("ResourceType")
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:53,代码来源:SystemBarTintManager.java

示例7: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19) public SystemBarTintManager(Activity activity) {

  Window win = activity.getWindow();
  ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    // check theme attrs
    int[] attrs = {
        android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation
    };
    TypedArray a = activity.obtainStyledAttributes(attrs);
    try {
      mStatusBarAvailable = a.getBoolean(0, false);
      mNavBarAvailable = a.getBoolean(1, false);
    } finally {
      a.recycle();
    }

    // check window flags
    WindowManager.LayoutParams winParams = win.getAttributes();
    int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
    if ((winParams.flags & bits) != 0) {
      mStatusBarAvailable = true;
    }
    bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
    if ((winParams.flags & bits) != 0) {
      mNavBarAvailable = true;
    }
  }

  mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
  // device might not have virtual navigation keys
  if (!mConfig.hasNavigtionBar()) {
    mNavBarAvailable = false;
  }

  if (mStatusBarAvailable) {
    setupStatusBarView(activity, decorViewGroup);
  }
  if (mNavBarAvailable) {
    setupNavBarView(activity, decorViewGroup);
  }
}
 
开发者ID:Lingzh0ng,项目名称:BrotherWeather,代码行数:51,代码来源:SystemBarTintManager.java

示例8: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus, android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:51,代码来源:SystemBarTintManager.java

示例9: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(0, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:devzwy,项目名称:KUtils,代码行数:52,代码来源:SystemBarTintManager.java

示例10: getThemeUpIndicator

import android.app.Activity; //导入方法依赖的package包/类
public static Drawable getThemeUpIndicator(Activity activity) {
    TypedArray a = activity.obtainStyledAttributes(THEME_ATTRS);
    Drawable result = a.getDrawable(0);
    a.recycle();
    return result;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:7,代码来源:ActionBarDrawerToggleHoneycomb.java

示例11: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
@SuppressWarnings("ResourceType")
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:dufangyu1990,项目名称:LeCatApp,代码行数:53,代码来源:SystemBarTintManager.java

示例12: SystemBarTintManager

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Constructor. Call this in the host activity onCreate method after its
 * content view has been set. You should always create new instances when
 * the host activity is recreated.
 *
 * @param activity The host activity.
 */
@TargetApi(19)
public SystemBarTintManager(Activity activity) {

    Window win = activity.getWindow();
    ViewGroup decorViewGroup = (ViewGroup) win.getDecorView();

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // check theme attrs
        int[] attrs = {android.R.attr.windowTranslucentStatus,
                android.R.attr.windowTranslucentNavigation};
        TypedArray a = activity.obtainStyledAttributes(attrs);
        try {
            mStatusBarAvailable = a.getBoolean(0, false);
            //mNavBarAvailable = a.getBoolean(1, false);
        } finally {
            a.recycle();
        }

        // check window flags
        WindowManager.LayoutParams winParams = win.getAttributes();
        int bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS;
        if ((winParams.flags & bits) != 0) {
            mStatusBarAvailable = true;
        }
        bits = WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION;
        if ((winParams.flags & bits) != 0) {
            mNavBarAvailable = true;
        }
    }

    mConfig = new SystemBarConfig(activity, mStatusBarAvailable, mNavBarAvailable);
    // device might not have virtual navigation keys
    if (!mConfig.hasNavigtionBar()) {
        mNavBarAvailable = false;
    }

    if (mStatusBarAvailable) {
        setupStatusBarView(activity, decorViewGroup);
    }
    if (mNavBarAvailable) {
        setupNavBarView(activity, decorViewGroup);
    }

}
 
开发者ID:gigabytedevelopers,项目名称:FireFiles,代码行数:52,代码来源:SystemBarTintManager.java


注:本文中的android.app.Activity.obtainStyledAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。