gpt4 book ai didi

android - ConstraintLayout 中的全景 ImageView

转载 作者:行者123 更新时间:2023-11-30 05:06:12 25 4
gpt4 key购买 nike

我有全景 View 的实现,在我切换到 ConstraintLayout 而不是 RelativeLayout 之前效果很好。现在我遇到的问题是 ImageView 将全景图像左边缘居中到设备的左边缘,而不是将中心图像居中到当前可见屏幕,所以基本上当我的陀螺仪旋转到左侧时它的黑色和当我转到最大右侧图像时被剪切。

以前我喜欢

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ImageView
android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"/>

</RelativeLayout>

现在我有

<android.support.constraint.ConstraintLayout 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"
android:background="@android:color/transparent">

<ImageView
android:id="@+id/image"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</android.support.constraint.ConstraintLayout>

知道我做错了什么或者约束如何以不同方式处理这个问题吗?

最佳答案

    android:layout_width="0dp"
android:layout_height="0dp"

这是错误的。如果将其更改为 match_parent 会怎样?

关于android - ConstraintLayout 中的全景 ImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54549954/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com