![](/img/trans.png)
[英]Is it true that when coding for android 360dp = the whole screen width?
[英]360dp in MDPI not matching in xxhdpi
我终于想通了。 这是构建ConstraintLayout来纠正这些问题的原因之一。 在这种特殊情况下,这与我使用的视图的纵横比有关。 因此,为了使其在左右活动中占据整个空间,我进行了以下操作并保持了宽高比。 请记住,我想要360 x 500的比例:
<com.mobile.myapp.customViews.SwippableViewPager
android:id="@+id/pager"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"
android:layout_marginTop="0dp"
app:layout_constraintDimensionRatio="H,360:500"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
此概述对我学习constraintLayout非常有用。
保证这种情况的另一种方法是使用已被弃用的视图组 : android percentRelativeLayout
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.