Comments (5)
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.
UI设计图上面是px为单位 布局里面dp我要怎么使用?
from phonescreenmatch.
能不能把箭头只的dp改成分辨率的写法
这样就不会混淆了! 这个问题容易混淆人,也不知道是多少分辨率的手机
from phonescreenmatch.
@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.
@ak47b51ak47 那怎么使用呢? UI 比如设计1920*1080的设计图 高宽在布局怎么写?有个button 设计图上是宽:100px,高:200px,适配单位都是dp 还要换算?
求指点
from phonescreenmatch.
Related Issues (14)
- 为什么这样写无法生成sp_19 HOT 3
- dp适配太多文件夹,能简化几个当下主流的几个吗? HOT 1
- 关于横竖屏切换问题? HOT 1
- 发现华为的mate8手机,demo测试按钮不能铺满屏幕
- bug解决:更新了dimen数据项,生成适配后为什么没有更新对应的dimens.xml文件
- 求联系方式 HOT 1
- 请问value 下特定的dimen.xml 是怎么来的呢
- 生成最小宽度,以代码计算出来的为主,还是以实际用公式计算出来的为主呢?
- 虚拟按键
- 关于屏幕适配的讨论
- 有没有参数可以改变sw<N>dp为w<N>dp?横版应用想做可用宽度的dp适配
- tv 可以用这种来适配吧 1080*1920
- 如何在java代码中动态设置尺寸
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phonescreenmatch.