當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。