Coder Social home page Coder Social logo

您好,首先感谢您的开源,你的库对我们这些开发者帮助非常的大,不过我有些不太理解的地方,想请教下dp转px的问题,这个问题不是您的库的问题 about screenadaptation HOT 2 CLOSED

wildma avatar wildma commented on June 9, 2024
您好,首先感谢您的开源,你的库对我们这些开发者帮助非常的大,不过我有些不太理解的地方,想请教下dp转px的问题,这个问题不是您的库的问题

from screenadaptation.

Comments (2)

wildma avatar wildma commented on June 9, 2024 1

@ideal-train

  1. 无关
  2. 无关

dp 转 px 只与屏幕密度有关。

你这里出现错误应该是你使用错误,dp2px() 方法的参数 dpValue 应该从 dimens 文件中获取,如下:

// 获取对应资源文件下的 dp 值
float pxValue2 = getResources().getDimension(R.dimen.dp_360);
// 将 px 值转换成 dp 值
int dpValue = ConvertUtils.px2dp(this, pxValue2);

这个文章中有说的,你回去再仔细看看。

from screenadaptation.

ideal-train avatar ideal-train commented on June 9, 2024

@ideal-train

  1. 无关
  2. 无关

dp 转 px 只与屏幕密度有关。

你这里出现错误应该是你使用错误,dp2px() 方法的参数 dpValue 应该从 dimens 文件中获取,如下:

// 获取对应资源文件下的 dp 值
float pxValue2 = getResources().getDimension(R.dimen.dp_360);
// 将 px 值转换成 dp 值
int dpValue = ConvertUtils.px2dp(this, pxValue2);

这个文章中有说的,你回去再仔细看看。

一下子明白了,谢谢帮助

from screenadaptation.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.