【问题标题】:Height of ImageView same as width from guidelinesImageView 的高度与指南中的宽度相同
【发布时间】:2018-06-02 19:29:30
【问题描述】:

在我的约束布局中,我有一个正方形的 ImageView。它的宽度由 GuideLines 定义:

<ImageView
    android:id="@+id/imageView2"
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:layout_constraintHorizontal_weight="1"
    app:layout_constraintTop_toTopOf="@id/guideline_h1"
    app:layout_constraintLeft_toLeftOf="@id/guideline100"
    app:layout_constraintRight_toLeftOf="@+id/guideline010"
    app:srcCompat="@drawable/choice04"/>

当然,我现在需要定义它的 constraintBottom 参数。但是,使用其他指南并不是一个好方法,因为在不同的屏幕尺寸上,% 值可能会改变比率。由于图像是一个正方形,我需要我的 ImageView 具有屏幕的 5% 到 45% 的宽度,这可以通过指南实现,并且它的高度是相同的。

【问题讨论】:

  • 分享您的整个布局和所需的输出
  • this ^F ratio

标签: android layout height width


【解决方案1】:

@pskink 的评论正是我想要的。线路:

app:layout_constraintDimensionRatio="1:1"

成功了。

【讨论】:

    猜你喜欢
    • 2019-03-05
    • 1970-01-01
    • 2014-03-15
    • 1970-01-01
    • 2015-01-18
    • 2018-12-29
    • 1970-01-01
    • 2018-06-01
    • 1970-01-01
    相关资源
    最近更新 更多