Giter Site home page Giter Site logo

关于dp使用! about phonescreenmatch HOT 5 OPEN

marren06 avatar marren06 commented on July 24, 2024
关于dp使用!

from phonescreenmatch.

Comments (5)

mengzhinan avatar mengzhinan commented on July 24, 2024

1、比喻一个按钮宽为100dp,高为50dp。按照你上面的用法,就是:
layout_width="@dimen/x100"

layout_height="@dimen/y50"

但是,如果我非要写成下面这样:
layout_width="@dimen/x100"

layout_height="@dimen/x50"

也不会错啊!故强制分开x和y已经没有意义了。也有很多冗余的值。
2、比喻联想A880手机,书面分辨率为960x540,好按照你的方法生成了对应的要values值。
然后你想写一个按钮,宽和高都占据屏幕的一半,于是写成x270,y480。运行时你会发现怎么按钮的高度大于屏幕的一半?你却不知其实手机运行时的有效分辨率为888x540。再加上现在很多手机开始流行底部虚拟按键,也是要占分辨率的。

故你非要以屏幕的分辨率比例来限制控件的宽高,无意思,且你也吼不住。如果把你适配的程序运行在平板或电视上,那岂不是悲剧了?运行在现在的全面屏上,也得重新开发调UI?

你会问,按照dp适配就没事?因为我不按照手机分辨率限制控件的高度,页面内容太多了,可以用scrollView啊。
3、1280x720 1920x1080两种常见的分辨率,你必须得要2套values文件吧。你会发现多数情况下,他们的实际手机宽度的dp值为 360dp。如果用手机宽度dp值做适配,是不是就只需要一个values文件了?

from phonescreenmatch.

marren06 avatar marren06 commented on July 24, 2024

UI设计图上面是px为单位 布局里面dp我要怎么使用?

from phonescreenmatch.

marren06 avatar marren06 commented on July 24, 2024

image
能不能把箭头只的dp改成分辨率的写法
image
这样就不会混淆了! 这个问题容易混淆人,也不知道是多少分辨率的手机

from phonescreenmatch.

ak47b51ak47 avatar ak47b51ak47 commented on July 24, 2024

@xuekaiqi 兄弟,你没理解适配原理,你上面说的是两套完全不同的适配方案,请阅读相关的文章:
http://blog.csdn.net/fesdgasdgasdg/article/details/52325590

http://blog.csdn.net/fesdgasdgasdg/article/details/78107653

http://blog.csdn.net/fesdgasdgasdg/article/details/78108169

http://blog.csdn.net/fesdgasdgasdg/article/details/78133821

from phonescreenmatch.

marren06 avatar marren06 commented on July 24, 2024

@ak47b51ak47 那怎么使用呢? UI 比如设计1920*1080的设计图 高宽在布局怎么写?有个button 设计图上是宽:100px,高:200px,适配单位都是dp 还要换算?
求指点

from phonescreenmatch.

Related Issues (14)

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.