本文整理汇总了Java中android.util.TypedValue.getFloat方法的典型用法代码示例。如果您正苦于以下问题:Java TypedValue.getFloat方法的具体用法?Java TypedValue.getFloat怎么用?Java TypedValue.getFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.util.TypedValue
的用法示例。
在下文中一共展示了TypedValue.getFloat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: scaleViewOnTablet
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Scales passed view with passed dimension on Tablets only
*/
public static void scaleViewOnTablet(Context context, View view, @DimenRes int dimenRes) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
boolean isTablet = context.getResources().getBoolean(R.bool.isTablet);
if (isTablet) {
TypedValue outValue = new TypedValue();
context.getResources().getValue(dimenRes, outValue, true);
float scale = outValue.getFloat();
view.setScaleX(scale);
view.setScaleY(scale);
}
}
}
示例2: initSlidingViewGroup
import android.util.TypedValue; //导入方法依赖的package包/类
private void initSlidingViewGroup() {
if (null == this.fragmentManager) {
return;
}
slidingViewGroup.setFragmentManager(this.fragmentManager);
slidingViewGroup.setTopFragment(youtubeFragment);
slidingViewGroup.setBottomFragment(new ImageViewFragment());
TypedValue typedValueX = new TypedValue();
getResources().getValue(R.dimen.scale_x_factor, typedValueX, true);
float scaleX = typedValueX.getFloat();
TypedValue typedValueY = new TypedValue();
getResources().getValue(R.dimen.scale_x_factor, typedValueY, true);
float scaleY = typedValueY.getFloat();
slidingViewGroup.setXScaleFactor(scaleX);
slidingViewGroup.setYScaleFactor(scaleY);
slidingViewGroup.setTopFragmentMarginBottom(context.getResources().getDimensionPixelOffset(R.dimen.top_fragment_margin));
slidingViewGroup.setTopViewHeight(screenHeight);
slidingViewGroup.setTopFragmentMarginRight(100);
slidingViewGroup.setClickToMaximizeEnabled(true);
// setSlidingListener();
}
示例3: init
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Init
*
* @param context context application context
*/
static public void init(@NonNull final Context context)
{
if (!Graphics.initDone)
{
final Resources resources = context.getApplicationContext().getResources();
// font factor for resolution
Graphics.PT2PX = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_PT, 1, resources.getDisplayMetrics());
// font factor for screen size
final TypedValue outValue = new TypedValue();
resources.getValue(R.dimen.font_factor, outValue, true);
Graphics.fontFactor = outValue.getFloat();
Graphics.initDone = true;
}
}
示例4: FeatureOverlayQuery
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Constructor
*
* @param context
* @param boundedOverlay
* @param featureTiles
* @since 1.2.5
*/
public FeatureOverlayQuery(Context context, BoundedOverlay boundedOverlay, FeatureTiles featureTiles) {
this.boundedOverlay = boundedOverlay;
this.featureTiles = featureTiles;
Resources resources = context.getResources();
// Get the screen percentage to determine when a feature is clicked
TypedValue screenPercentage = new TypedValue();
resources.getValue(R.dimen.map_feature_overlay_click_screen_percentage, screenPercentage, true);
screenClickPercentage = screenPercentage.getFloat();
maxFeaturesInfo = resources.getBoolean(R.bool.map_feature_overlay_max_features_info);
featuresInfo = resources.getBoolean(R.bool.map_feature_overlay_features_info);
FeatureDao featureDao = featureTiles.getFeatureDao();
featureInfoBuilder = new FeatureInfoBuilder(context, featureDao);
}
示例5: getFloat
import android.util.TypedValue; //导入方法依赖的package包/类
@UiThread // Implicit synchronization for use of shared resource VALUE.
public static float getFloat(Context context, @DimenRes int id) {
TypedValue value = VALUE;
context.getResources().getValue(id, value, true);
if (value.type == TypedValue.TYPE_FLOAT) {
return value.getFloat();
}
throw new Resources.NotFoundException("Resource ID #0x" + Integer.toHexString(id)
+ " type #0x" + Integer.toHexString(value.type) + " is not valid");
}
示例6: parseValue
import android.util.TypedValue; //导入方法依赖的package包/类
Description parseValue(TypedValue value) {
Description d = new Description();
if (value == null) {
d.type = ABSOLUTE;
d.value = 0;
} else {
if (value.type == TypedValue.TYPE_FRACTION) {
d.type = (value.data & TypedValue.COMPLEX_UNIT_MASK) ==
TypedValue.COMPLEX_UNIT_FRACTION_PARENT ?
RELATIVE_TO_PARENT : RELATIVE_TO_SELF;
d.value = TypedValue.complexToFloat(value.data);
return d;
} else if (value.type == TypedValue.TYPE_FLOAT) {
d.type = ABSOLUTE;
d.value = value.getFloat();
return d;
} else if (value.type >= TypedValue.TYPE_FIRST_INT &&
value.type <= TypedValue.TYPE_LAST_INT) {
d.type = ABSOLUTE;
d.value = value.data;
return d;
}
}
d.type = ABSOLUTE;
d.value = 0.0f;
return d;
}
示例7: initialize
import android.util.TypedValue; //导入方法依赖的package包/类
private void initialize(Context context)
{
DisplayMetrics metrics = context.getResources().getDisplayMetrics();
int padDp = context.getResources().getInteger(R.integer.selection_dot_padding);
int sizeDp = context.getResources().getInteger(R.integer.selection_dot_size);
TypedValue outValue = new TypedValue();
getResources().getValue(R.dimen.selection_dot_scale, outValue, true);
float scale = outValue.getFloat();
selectionHandlePadPx = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, padDp, metrics);
selectionHandleSizePx = (int) (scale * TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, sizeDp, metrics));
}
示例8: getAttrFloatOrFraction
import android.util.TypedValue; //导入方法依赖的package包/类
float getAttrFloatOrFraction(Context context, AttributeSet attrs, int attr, float defaultValue, float base, float pbase) {
TypedArray a = obtainAttributes(context.getResources(), context.getTheme(), attrs, new int[]{attr});
TypedValue tv = a.peekValue(0);
float v = defaultValue;
if (tv != null) {
boolean isFraction = tv.type == TypedValue.TYPE_FRACTION;
v = isFraction ? tv.getFraction(base, pbase) : tv.getFloat();
}
a.recycle();
return v;
}
示例9: initAttributes
import android.util.TypedValue; //导入方法依赖的package包/类
private void initAttributes(Context context, AttributeSet attrs) {
if (attrs != null) {
final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.CarouselPicker);
itemsVisible = array.getInteger(R.styleable.CarouselPicker_items_visible, itemsVisible);
switch (itemsVisible) {
case 3:
TypedValue threeValue = new TypedValue();
getResources().getValue(R.dimen.three_items, threeValue, true);
divisor = threeValue.getFloat();
break;
case 5:
TypedValue fiveValue = new TypedValue();
getResources().getValue(R.dimen.five_items, fiveValue, true);
divisor = fiveValue.getFloat();
break;
case 7:
TypedValue sevenValue = new TypedValue();
getResources().getValue(R.dimen.seven_items, sevenValue, true);
divisor = sevenValue.getFloat();
break;
default:
divisor = 3;
break;
}
array.recycle();
}
}
示例10: PhoneTabSwitcherLayout
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Creates a new layout, which implements the functionality of a {@link TabSwitcher} on
* smartphones.
*
* @param tabSwitcher
* The tab switcher, the layout belongs to, as an instance of the class {@link
* TabSwitcher}. The tab switcher may not be null
* @param model
* The model of the tab switcher, the layout belongs to, as an instance of the class
* {@link TabSwitcherModel}. The model may not be null
* @param arithmetics
* The arithmetics, which should be used by the layout, as an instance of the class
* {@link PhoneArithmetics}. The arithmetics may not be null
* @param style
* The style, which allows to retrieve style attributes of the tab switcher, as an
* instance of the class {@link TabSwitcherStyle}. The style may not be null
* @param touchEventDispatcher
* The dispatcher, which is used to dispatch touch events to event handlers, as an
* instance of the class {@link TouchEventDispatcher}. The dispatcher may not be null
*/
public PhoneTabSwitcherLayout(@NonNull final TabSwitcher tabSwitcher,
@NonNull final TabSwitcherModel model,
@NonNull final PhoneArithmetics arithmetics,
@NonNull final TabSwitcherStyle style,
@NonNull final TouchEventDispatcher touchEventDispatcher) {
super(tabSwitcher, model, arithmetics, style, touchEventDispatcher);
Resources resources = tabSwitcher.getResources();
stackedTabCount = resources.getInteger(R.integer.phone_stacked_tab_count);
tabInset = resources.getDimensionPixelSize(R.dimen.tab_inset);
tabBorderWidth = resources.getDimensionPixelSize(R.dimen.tab_border_width);
tabTitleContainerHeight =
resources.getDimensionPixelSize(R.dimen.tab_title_container_height);
maxCameraDistance = resources.getDimensionPixelSize(R.dimen.max_camera_distance);
TypedValue typedValue = new TypedValue();
resources.getValue(R.dimen.swiped_tab_scale, typedValue, true);
swipedTabScale = typedValue.getFloat();
resources.getValue(R.dimen.swiped_tab_alpha, typedValue, true);
swipedTabAlpha = typedValue.getFloat();
showSwitcherAnimationDuration =
resources.getInteger(R.integer.show_switcher_animation_duration);
hideSwitcherAnimationDuration =
resources.getInteger(R.integer.hide_switcher_animation_duration);
toolbarVisibilityAnimationDuration =
resources.getInteger(R.integer.toolbar_visibility_animation_duration);
toolbarVisibilityAnimationDelay =
resources.getInteger(R.integer.toolbar_visibility_animation_delay);
swipeAnimationDuration = resources.getInteger(R.integer.swipe_animation_duration);
relocateAnimationDuration = resources.getInteger(R.integer.relocate_animation_duration);
revertOvershootAnimationDuration =
resources.getInteger(R.integer.revert_overshoot_animation_duration);
revealAnimationDuration = resources.getInteger(R.integer.reveal_animation_duration);
peekAnimationDuration = resources.getInteger(R.integer.peek_animation_duration);
emptyViewAnimationDuration = resources.getInteger(R.integer.empty_view_animation_duration);
maxStartOvershootAngle = resources.getInteger(R.integer.max_start_overshoot_angle);
maxEndOvershootAngle = resources.getInteger(R.integer.max_end_overshoot_angle);
swipedTabDistance = resources.getDimensionPixelSize(R.dimen.swiped_tab_distance);
tabViewBottomMargin = -1;
toolbarAnimation = null;
}
示例11: PhoneTabSwitcherLayout
import android.util.TypedValue; //导入方法依赖的package包/类
/**
* Creates a new layout, which implements the functionality of a {@link TabSwitcher} on
* smartphones.
*
* @param tabSwitcher
* The tab switcher, the layout belongs to, as an instance of the class {@link
* TabSwitcher}. The tab switcher may not be null
* @param model
* The model of the tab switcher, the layout belongs to, as an instance of the class
* {@link TabSwitcherModel}. The model may not be null
* @param arithmetics
* The arithmetics, which should be used by the layout, as an instance of the class
* {@link PhoneArithmetics}. The arithmetics may not be null
*/
public PhoneTabSwitcherLayout(@NonNull final TabSwitcher tabSwitcher,
@NonNull final TabSwitcherModel model,
@NonNull final PhoneArithmetics arithmetics) {
super(tabSwitcher, model, arithmetics);
Resources resources = tabSwitcher.getResources();
tabInset = resources.getDimensionPixelSize(R.dimen.tab_inset);
tabBorderWidth = resources.getDimensionPixelSize(R.dimen.tab_border_width);
tabTitleContainerHeight =
resources.getDimensionPixelSize(R.dimen.tab_title_container_height);
stackedTabCount = resources.getInteger(R.integer.stacked_tab_count);
stackedTabSpacing = resources.getDimensionPixelSize(R.dimen.stacked_tab_spacing);
maxCameraDistance = resources.getDimensionPixelSize(R.dimen.max_camera_distance);
TypedValue typedValue = new TypedValue();
resources.getValue(R.dimen.swiped_tab_scale, typedValue, true);
swipedTabScale = typedValue.getFloat();
resources.getValue(R.dimen.swiped_tab_alpha, typedValue, true);
swipedTabAlpha = typedValue.getFloat();
showSwitcherAnimationDuration =
resources.getInteger(R.integer.show_switcher_animation_duration);
hideSwitcherAnimationDuration =
resources.getInteger(R.integer.hide_switcher_animation_duration);
toolbarVisibilityAnimationDuration =
resources.getInteger(R.integer.toolbar_visibility_animation_duration);
toolbarVisibilityAnimationDelay =
resources.getInteger(R.integer.toolbar_visibility_animation_delay);
swipeAnimationDuration = resources.getInteger(R.integer.swipe_animation_duration);
clearAnimationDelay = resources.getInteger(R.integer.clear_animation_delay);
relocateAnimationDuration = resources.getInteger(R.integer.relocate_animation_duration);
relocateAnimationDelay = resources.getInteger(R.integer.relocate_animation_delay);
revertOvershootAnimationDuration =
resources.getInteger(R.integer.revert_overshoot_animation_duration);
revealAnimationDuration = resources.getInteger(R.integer.reveal_animation_duration);
peekAnimationDuration = resources.getInteger(R.integer.peek_animation_duration);
maxStartOvershootAngle = resources.getInteger(R.integer.max_start_overshoot_angle);
maxEndOvershootAngle = resources.getInteger(R.integer.max_end_overshoot_angle);
tabViewBottomMargin = -1;
toolbarAnimation = null;
}
示例12: init
import android.util.TypedValue; //导入方法依赖的package包/类
private void init(Context context, AttributeSet attrs) {
if (isInEditMode()) {
return;
}
LayoutInflater layoutInflater =
(LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
layoutInflater.inflate(R.layout.number_picker, this);
TypedArray typedArray =
context.obtainStyledAttributes(attrs, R.styleable.ScrollableNumberPicker);
Resources res = getResources();
downIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconDown, downIcon);
upIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconUp, upIcon);
leftIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconLeft, leftIcon);
rightIcon = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonIconRight, rightIcon);
mMinValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_minValue,
res.getInteger(R.integer.default_minValue));
mMaxValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_maxValue,
res.getInteger(R.integer.default_maxValue));
mStepSize = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_stepSize,
res.getInteger(R.integer.default_stepSize));
mUpdateIntervalMillis = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_updateInterval,
res.getInteger(R.integer.default_updateInterval));
mOrientation = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_orientation,
LinearLayout.HORIZONTAL);
mValue = typedArray.getInt(R.styleable.ScrollableNumberPicker_snp_value,
res.getInteger(R.integer.default_value));
mValueTextSize = typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_value_text_size,
INVALID_RES);
mValueTextColor = typedArray.getColor(R.styleable.ScrollableNumberPicker_snp_value_text_color,
0);
mValueTextAppearanceResId = typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_value_text_appearance, INVALID_RES);
mScrollEnabled = typedArray.getBoolean(R.styleable.ScrollableNumberPicker_snp_scrollEnabled,
res.getBoolean(R.bool.default_scrollEnabled));
mButtonColorStateList = ContextCompat.getColorStateList(context, typedArray.getResourceId(R.styleable.ScrollableNumberPicker_snp_buttonBackgroundTintSelector, R.color.btn_tint_selector));
mValueMarginStart = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_start));
mValueMarginEnd = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_valueMarginStart, res.getDimension(R.dimen.default_value_margin_end));
mButtonPaddingLeft = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingLeft, res.getDimension(R.dimen.default_button_padding_left));
mButtonPaddingRight = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingRight, res.getDimension(R.dimen.default_button_padding_right));
mButtonPaddingTop = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingTop, res.getDimension(R.dimen.default_button_padding_top));
mButtonPaddingBottom = (int) typedArray.getDimension(R.styleable.ScrollableNumberPicker_snp_buttonPaddingBottom, res.getDimension(R.dimen.default_button_padding_bottom));
TypedValue outValue = new TypedValue();
res.getValue(R.dimen.default_button_scale_factor, outValue, true);
float defaultValue = outValue.getFloat();
mButtonTouchScaleFactor = typedArray.getFloat(R.styleable.ScrollableNumberPicker_snp_buttonTouchScaleFactor, defaultValue);
typedArray.recycle();
initViews();
mAutoIncrement = false;
mAutoDecrement = false;
mUpdateIntervalHandler = new Handler();
}
示例13: getAttrFloatValue
import android.util.TypedValue; //导入方法依赖的package包/类
public static float getAttrFloatValue(Context context, int attrRes){
TypedValue typedValue = new TypedValue();
context.getTheme().resolveAttribute(attrRes, typedValue, true);
return typedValue.getFloat();
}
示例14: getFloatFromResources
import android.util.TypedValue; //导入方法依赖的package包/类
public static float getFloatFromResources(Context context, @DimenRes int dimenRes) {
TypedValue tempVal = new TypedValue();
context.getResources().getValue(dimenRes, tempVal, true);
return tempVal.getFloat();
}
示例15: init
import android.util.TypedValue; //导入方法依赖的package包/类
private void init(AttributeSet attrs, int defStyleAttr) {
final TypedArray a = getContext().obtainStyledAttributes(attrs,
R.styleable.SuwSetupWizardLayout, defStyleAttr, 0);
// Set the background from XML, either directly or built from a bitmap tile
final Drawable background =
a.getDrawable(R.styleable.SuwSetupWizardLayout_suwBackground);
if (background != null) {
setLayoutBackground(background);
} else {
final Drawable backgroundTile =
a.getDrawable(R.styleable.SuwSetupWizardLayout_suwBackgroundTile);
if (backgroundTile != null) {
setBackgroundTile(backgroundTile);
}
}
// Set the illustration from XML, either directly or built from image + horizontal tile
final Drawable illustration =
a.getDrawable(R.styleable.SuwSetupWizardLayout_suwIllustration);
if (illustration != null) {
setIllustration(illustration);
} else {
final Drawable illustrationImage =
a.getDrawable(R.styleable.SuwSetupWizardLayout_suwIllustrationImage);
final Drawable horizontalTile = a.getDrawable(
R.styleable.SuwSetupWizardLayout_suwIllustrationHorizontalTile);
if (illustrationImage != null && horizontalTile != null) {
setIllustration(illustrationImage, horizontalTile);
}
}
// Set the top padding of the illustration
int decorPaddingTop = a.getDimensionPixelSize(
R.styleable.SuwSetupWizardLayout_suwDecorPaddingTop, -1);
if (decorPaddingTop == -1) {
decorPaddingTop = getResources().getDimensionPixelSize(R.dimen.suw_decor_padding_top);
}
setDecorPaddingTop(decorPaddingTop);
// Set the illustration aspect ratio. See Illustration.setAspectRatio(float). This will
// override suwIllustrationPaddingTop if its value is not 0.
float illustrationAspectRatio = a.getFloat(
R.styleable.SuwSetupWizardLayout_suwIllustrationAspectRatio, -1f);
if (illustrationAspectRatio == -1f) {
final TypedValue out = new TypedValue();
getResources().getValue(R.dimen.suw_illustration_aspect_ratio, out, true);
illustrationAspectRatio = out.getFloat();
}
setIllustrationAspectRatio(illustrationAspectRatio);
// Set the header text
final CharSequence headerText =
a.getText(R.styleable.SuwSetupWizardLayout_suwHeaderText);
if (headerText != null) {
setHeaderText(headerText);
}
a.recycle();
}