本文整理匯總了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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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));
}