三星S3不同的维度 - 720x1280,xhdpi,306ppi如何为三星S3和摩托X
摩托罗拉极限摩托 - 720x1280,xhdpi,312 ppi的
我需要为这些设备提供不同的dimen
。
我已阅读Supporting Multiple Screens但仍然没有找到一个解决办法
貌似问题,因为Motorola Moto X
没有硬件按钮(后退,菜单,主页)
我怎样才能做到这一点?
三星S3不同的维度 - 720x1280,xhdpi,306ppi如何为三星S3和摩托X
摩托罗拉极限摩托 - 720x1280,xhdpi,312 ppi的
我需要为这些设备提供不同的dimen
。
我已阅读Supporting Multiple Screens但仍然没有找到一个解决办法
貌似问题,因为Motorola Moto X
没有硬件按钮(后退,菜单,主页)
我怎样才能做到这一点?
您可以使用谷歌图书馆PercentRelativeLayout
与此库,你可以设置width
,height
和您的看法以百分比这是因为所有的屏幕是很大的margin
它们看起来是一样的,当然也不是很难的代码吧。这里例如:
<android.support.percent.PercentRelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
app:layout_widthPercent="50%"
app:layout_heightPercent="50%"
app:layout_marginTopPercent="25%"
app:layout_marginLeftPercent="25%"/>
</android.support.percent.PercentRelativeLayout>
您必须将此帮助加入这一行你build.gradle
dependencies {
compile 'com.android.support:percent:23.2.0'
}
和官方文件由谷歌https://developer.android.com/reference/android/support/percent/PercentRelativeLayout.html 希望对你的情况!
感谢您的回答,我之前不知道这个图书馆。其实我已经通过其他方式解决了我的问题(只是将RelativeLayout更改为LinearLayout),反正+1 – CAMOBAP
您是否尝试过'smallestWidth'?我认为它应该诀窍 – pamobo0609
@ pamobo0609你的意思是'sw312'或'sw306'? – CAMOBAP
“我需要为这些设备提供不同的尺寸” - 然后你有一个严重的UI问题。有超过* 8,000 *的Android设备型号。就时间和硬件购置成本而言,为每一个尺寸创建量身定制的尺寸将是非常昂贵的建议。 – CommonsWare