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


Java TypedValue.complexToDimensionPixelSize方法代码示例

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


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

示例1: setStatusBarTranslucent

import android.util.TypedValue; //导入方法依赖的package包/类
@TargetApi(19)
protected void setStatusBarTranslucent(boolean makeTranslucent) {
    View v = findViewById(R.id.activity_main);
    if (v != null) {
        int paddingTop = 0;
        TypedValue tv = new TypedValue();
        getTheme().resolveAttribute(0, tv, true);
        paddingTop += TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
        v.setPadding(0, makeTranslucent ? paddingTop : 0, 0, 0);
    }

    if (makeTranslucent) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    } else {
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }
}
 
开发者ID:Adyen,项目名称:adyen-android,代码行数:18,代码来源:MainActivity.java

示例2: getTopY

import android.util.TypedValue; //导入方法依赖的package包/类
@SuppressLint("PrivateResource")
private int getTopY(@NonNull DisplayMetrics metrics) {
    final int statusBarHeight;
    final int actionBarHeight;
    {
        final int resourceId = getResources().getIdentifier("status_bar_height", "dimen", "android");
        statusBarHeight = resourceId > 0 ? getResources().getDimensionPixelSize(resourceId) : 0;
    }
    final TypedValue value = new TypedValue();

    if (super.getTheme().resolveAttribute(R.attr.actionBarSize, value, true)) {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(value.data, metrics);

    } else {
        actionBarHeight = getResources().getDimensionPixelSize(R.dimen.abc_action_bar_default_height_material);
    }
    return statusBarHeight + actionBarHeight;
}
 
开发者ID:RollnCode,项目名称:BackTube,代码行数:19,代码来源:PlayerService.java

示例3: getActionBarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * 获取ActionBar高度
 * @param context
 * @return
 */
public static int getActionBarHeight(Context context) {
    int actionBarHeight = 0;
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize,tv, true)){
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
                context.getResources().getDisplayMetrics());
    }
    return actionBarHeight;
}
 
开发者ID:coopese,项目名称:qmui,代码行数:15,代码来源:QMUIDisplayHelper.java

示例4: getActionBarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
@TargetApi(14)
private int getActionBarHeight(Context context) {
    int result = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
        TypedValue tv = new TypedValue();
        context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true);
        result = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }
    return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SystemBarTintManager.java

示例5: setStatusBarColor

import android.util.TypedValue; //导入方法依赖的package包/类
static void setStatusBarColor(Activity activity, int statusColor) {
    Window window = activity.getWindow();
    //设置Window为全透明
    window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);

    ViewGroup mContentView = (ViewGroup) window.findViewById(Window.ID_ANDROID_CONTENT);
    //获取父布局
    View mContentChild = mContentView.getChildAt(0);
    //获取状态栏高度
    int statusBarHeight = getStatusBarHeight(activity);

    //如果已经存在假状态栏则移除,防止重复添加
    removeFakeStatusBarViewIfExist(activity);
    //添加一个View来作为状态栏的填充
    addFakeStatusBarView(activity, statusColor, statusBarHeight);
    //设置子控件到状态栏的间距
    addMarginTopToContentChild(mContentChild, statusBarHeight);
    //不预留系统栏位置
    if (mContentChild != null) {
        ViewCompat.setFitsSystemWindows(mContentChild, false);
    }
    //如果在Activity中使用了ActionBar则需要再将布局与状态栏的高度跳高一个ActionBar的高度,否则内容会被ActionBar遮挡
    int action_bar_id = activity.getResources().getIdentifier("action_bar", "id", activity.getPackageName());
    View view = activity.findViewById(action_bar_id);
    if (view != null) {
       TypedValue typedValue = new TypedValue();
        if (activity.getTheme().resolveAttribute(R.attr.actionBarSize, typedValue, true)) {
            int actionBarHeight = TypedValue.complexToDimensionPixelSize(typedValue.data, activity.getResources().getDisplayMetrics());
            Eyes.setContentTopPadding(activity, actionBarHeight);
        }
    }
}
 
开发者ID:bigjelly,项目名称:AndFast,代码行数:33,代码来源:EyesKitKat.java

示例6: getActionBarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * 获取ActionBar高度
 *
 * @param activity activity
 * @return ActionBar高度
 */
public static int getActionBarHeight(@NonNull final Activity activity) {
    TypedValue tv = new TypedValue();
    if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
    }
    return 0;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:14,代码来源:BarUtils.java

示例7: getActionBarSize

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * Get ActionBar size.
 *
 * @return
 */
public static int getActionBarSize() {
    int actionBarSize = 0;
    TypedValue tv = new TypedValue();
    if (CommonApp.getInstance().getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarSize = TypedValue.complexToDimensionPixelSize(tv.data,
                CommonApp.getInstance().getResources().getDisplayMetrics());
    }
    return actionBarSize;
}
 
开发者ID:vsona,项目名称:RxJava2RetrofitDemo,代码行数:15,代码来源:ScreenUtils.java

示例8: ImageAdapter

import android.util.TypedValue; //导入方法依赖的package包/类
public ImageAdapter(Context context) {
    super();
    mContext = context;
    mImageViewLayoutParams = new GridView.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(
            android.R.attr.actionBarSize, tv, true)) {
        mActionBarHeight = TypedValue.complexToDimensionPixelSize(
                tv.data, context.getResources().getDisplayMetrics());
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:ImageGridFragment.java

示例9: measureMainView

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * Measure the root view and get bounds.
 */
private void measureMainView() {
    getLocalVisibleRect(mRootViewBound);

    //Get the height of the actionbar if we have any actionbar and add it to the top
    TypedValue tv = new TypedValue();
    if (mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        mRootViewBound.top = mRootViewBound.top
                + TypedValue.complexToDimensionPixelSize(tv.data, getResources().getDisplayMetrics());
    }
}
 
开发者ID:kevalpatel2106,项目名称:PasscodeView,代码行数:14,代码来源:PasscodeView.java

示例10: getToolbarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
public static int getToolbarHeight(Context context) {
    TypedValue tv = new TypedValue();
    if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }
    return 0;
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:8,代码来源:WindowManagerHelper.java

示例11: getThemeAttrDimen

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * Get a dimen from the attribute theme
 *
 * @param context        theme context
 * @param attributeDimen the attribute dimen, ex R.attr.actionBarSize
 * @return the dimen pixel size, if it exists in the theme context. Otherwise, -1
 */
public static float getThemeAttrDimen(@NonNull Context context, @AttrRes int attributeDimen) {
    TypedValue tv = new TypedValue();

    int value = -1;
    if (context.getTheme().resolveAttribute(attributeDimen, tv, true)) {
        value = TypedValue.complexToDimensionPixelSize(tv.data, context.getResources().getDisplayMetrics());
    }
    return value;
}
 
开发者ID:jumaallan,项目名称:AndelaTrackChallenge,代码行数:17,代码来源:Easel.java

示例12: getActionBarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * 获取ActionBar高度
 *
 * @param activity activity
 * @return ActionBar高度
 */
public static int getActionBarHeight(Activity activity) {
    TypedValue tv = new TypedValue();
    if (activity.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        return TypedValue.complexToDimensionPixelSize(tv.data, activity.getResources().getDisplayMetrics());
    }
    return 0;
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:14,代码来源:BarUtils.java

示例13: getToolbarHeight

import android.util.TypedValue; //导入方法依赖的package包/类
/**
 * Get toolbar height
 * @param activity Activity
 * @return int
 */
public static int getToolbarHeight(Activity activity){
    TypedValue tv = new TypedValue();
    if (activity.getTheme().resolveAttribute(R.attr.actionBarSize, tv, true)) {
        Log.d(TAG, "Toolbar found, height: " + String.valueOf(TypedValue.complexToDimensionPixelSize(tv.data,activity.getApplicationContext().getResources().getDisplayMetrics())));
        return TypedValue.complexToDimensionPixelSize(tv.data,activity.getApplicationContext().getResources().getDisplayMetrics());
    }else{
        Log.d(TAG, "Toolbar not found, height: 0");
        return 0;
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:16,代码来源:Utils.java

示例14: initView

import android.util.TypedValue; //导入方法依赖的package包/类
private View initView(View view) {
    mRootLayout = new FrameLayout(mContext);
    FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.MATCH_PARENT);
    mRootLayout.setLayoutParams(layoutParams);
    mRootLayout.addView(view);

    TypedValue tv = new TypedValue();
    int actionBarHeight = 0;
    if (mIsLoadingMargin && mContext.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) {
        actionBarHeight = TypedValue.complexToDimensionPixelSize(tv.data,
                getResources().getDisplayMetrics());
    }
    FrameLayout.LayoutParams flp = new FrameLayout.LayoutParams(
            FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT);
    flp.topMargin = actionBarHeight;

    mErrorView = LayoutInflater.from(mContext).inflate(R.layout.load_failed, null);
    mErrorView.setVisibility(View.GONE);
    mErrorView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            retryLoading();
        }
    });
    mRootLayout.addView(mErrorView, flp);

    mLoadingView = LayoutInflater.from(mContext).inflate(R.layout.loading, null);
    mLoadingView.setVisibility(View.GONE);
    mRootLayout.addView(mLoadingView, flp);

    mFloatLoadingView = LayoutInflater.from(mContext).inflate(R.layout.float_loading, null);
    mFloatLoadingView.setVisibility(View.GONE);
    mRootLayout.addView(mFloatLoadingView, flp);

    return mRootLayout;
}
 
开发者ID:HanyeeWang,项目名称:GeekZone,代码行数:39,代码来源:BaseFragment.java

示例15: getAttrDimen

import android.util.TypedValue; //导入方法依赖的package包/类
public static int getAttrDimen(Context context, int attrRes){
    TypedValue typedValue = new TypedValue();
    context.getTheme().resolveAttribute(attrRes, typedValue, true);
    return TypedValue.complexToDimensionPixelSize(typedValue.data, QMUIDisplayHelper.getDisplayMetrics(context));
}
 
开发者ID:coopese,项目名称:qmui,代码行数:6,代码来源:QMUIResHelper.java


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