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


Java Dimension.PX属性代码示例

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


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

示例1: sizePX

/**
 * @see android.text.style.AbsoluteSizeSpan#AbsoluteSizeSpan(int)
 */
public static Span sizePX(@Dimension(unit = Dimension.PX) final int px) {
    return new Span(new AbsoluteSizeSpanBuilder(px, false));
}
 
开发者ID:neworld,项目名称:spanner,代码行数:6,代码来源:Spans.java

示例2: testPxToDp

@Test
public void testPxToDp() {
  @Dimension(unit = Dimension.PX) float px = 3.5f;
  Assert.assertEquals(1.4f, MetricsHelper.pxToDp(resources, px));
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:5,代码来源:MetricsHelperTest.java

示例3: dpToPx

@Dimension(unit = Dimension.PX)
int dpToPx(@Dimension(unit = Dimension.DP) int dps) {
  return Math.round(getResources().getDisplayMetrics().density * dps);
}
 
开发者ID:material-components,项目名称:material-components-android,代码行数:4,代码来源:TabLayout.java

示例4: dpToPx

/**
 * Converts the {@code dp} value to pixels dimension.
 *
 * @param resources to obtain the density value
 * @param dp the value in dp dimension
 * @return the converted {@code dp} value to pixels
 */
@Dimension(unit = Dimension.PX)
public static float dpToPx(@NonNull Resources resources, @Dimension(unit = Dimension.DP) float dp) {
  return dp * resources.getDisplayMetrics().density;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:11,代码来源:MetricsHelper.java

示例5: spToPx

/**
 * Converts the {@code sp} value to pixels dimension.
 *
 * @param resources to obtain the density value
 * @param sp the value in sp dimension
 * @return the converted {@code sp} value to pixels
 */
@Dimension(unit = Dimension.PX)
public static float spToPx(@NonNull Resources resources, @Dimension(unit = Dimension.SP) float sp) {
  return sp * resources.getDisplayMetrics().scaledDensity;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:11,代码来源:MetricsHelper.java

示例6: dpToPxInt

/**
 * Converts the {@code dp} value to pixels dimension.
 *
 * @param resources to obtain the density value
 * @param dp the value in dp dimension
 * @return the converted {@code dp} value to integer pixels
 */
@Dimension(unit = Dimension.PX)
public static int dpToPxInt(@NonNull Resources resources, @Dimension(unit = Dimension.DP) float dp) {
  return (int) dpToPx(resources, dp);
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:11,代码来源:MetricsHelper.java

示例7: dimResToPxInt

/**
 * Converts the given {@code dimenId} resource to pixels.
 *
 * @param resources to obtain the density value
 * @param dimenId the resource to convert
 * @return the converted {@code dimenId} resource value to integer pixels
 */
@Dimension(unit = Dimension.PX)
public static int dimResToPxInt(@NonNull Resources resources, @DimenRes int dimenId) {
  return (int) resources.getDimension(dimenId);
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:11,代码来源:MetricsHelper.java

示例8: pxToDp

/**
 * Converts the {@code px} value to dp.
 *
 * @param resources to obtain the density value
 * @param px the value in pixels to convert to dp
 * @return the converted {@code px} value to dp
 */
@Dimension(unit = Dimension.DP)
public static float pxToDp(@NonNull Resources resources, @Dimension(unit = Dimension.PX) float px) {
  return px / resources.getDisplayMetrics().density;
}
 
开发者ID:xmartlabs,项目名称:bigbang,代码行数:11,代码来源:MetricsHelper.java


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