我正在设计音乐播放器的布局,但是当我使用虚拟设备Nexus 5渲染时,我根本不会遇到任何问题
但是当我用Nexus 7渲染时
它显示相同大小的图像.
发布我的照片的屏幕截图.
希望能得到你们的一些解决方案.
解决方法:
您必须遵循此 *** 作才能支持多个设备:
屏幕密度的变化.
xlarge screens are at least 960dp x 720dplarge screens are at least 640dp x 480dpnormal screens are at least 470dp x 320dpsmall screens are at least 426dp x 320dp
制作此布局文件,以便它对所有设备都相同.
res/layout/main_activity.xml # For handsets (smaller than 600dp available wIDth)res/layout-sw600dp/main_activity.xml # For 7” tablets (600dp wIDe and bigger)res/layout-sw720dp/main_activity.xml # For 10” tablets (720dp wIDe and bigger)
对于布局,
res/layout/my_layout.xml // layout for normal screen size ("default")res/layout-large/my_layout.xml // layout for large screen sizeres/layout-xlarge/my_layout.xml // layout for extra-large screen sizeres/layout-xlarge-land/my_layout.xml // layout for extra-large in landscape orIEntation
对于图像
res/drawable-mdpi/graphic.png // bitmap for medium-densityres/drawable-hdpi/graphic.png // bitmap for high-densityres/drawable-xhdpi/graphic.png // bitmap for extra-high-densityres/drawable-xxhdpi/graphic.png // bitmap for extra-extra-high-density
对于图标
res/mipmap-mdpi/my_icon.png // launcher icon for medium-densityres/mipmap-hdpi/my_icon.png // launcher icon for high-densityres/mipmap-xhdpi/my_icon.png // launcher icon for extra-high-densityres/mipmap-xxhdpi/my_icon.png // launcher icon for extra-extra-high-densityres/mipmap-xxxhdpi/my_icon.png // launcher icon for extra-extra-extra-high-density
对于Launcher图标
36x36 (0.75x) for low-density48x48 (1.0x baseline) for medium-density72x72 (1.5x) for high-density96x96 (2.0x) for extra-high-density180x180 (3.0x) for extra-extra-high-density192x192 (4.0x) for extra-extra-extra-high-density (launcher icon only; see note above)
NOTE: Always try to use SP whenever you deal with
textSize
, liketextsize=12sp
使用预定义的textAppearance:
It will set text size automatically as per device density. <TextVIEw androID:textAppearance="?androID:attr/textAppearanceSmall"/> <TextVIEw androID:textAppearance="?androID:attr/textAppearanceMedium"/> <TextVIEw androID:textAppearance="?androID:attr/textAppearanceLarge" />Sample usage: <TextVIEw androID:text="Sample Text - Small" /> <TextVIEw androID:text="Sample Text - Medium" /> <TextVIEw androID:text="Sample Text - Large" />
请访问Supporting Multiple Screens
总结以上是内存溢出为你收集整理的如何在Android Studio中的相应Android设备中获取适当的图像全部内容,希望文章能够帮你解决如何在Android Studio中的相应Android设备中获取适当的图像所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)