【发布时间】:2019-09-30 07:31:13
【问题描述】:
即使我将 父布局 更改为相对布局,我的 ImageView 也不会显示在前面。
我想这是一个我不知道的最小错误。
例如:
有一个片段(地图),一个按钮,还有这个地图的图例。
按钮通常在运行时显示,但图例不显示。
更多信息,这里是 xml 代码。
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment
android:id="@+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
tools:layout_editor_absoluteX="8dp" />
<Button
android:id="@+id/select"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginTop="16dp"
android:layout_marginEnd="13dp"
android:backgroundTint="@color/colorAccent"
android:text="select"
android:textColor="@color/colorPrimary" />
<ImageView
android:id="@+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentBottom="true"
android:adjustViewBounds="true"
android:contentDescription="legend"
android:translationZ="1000dp"
app:srcCompat="@drawable/legend_imageview" />
【问题讨论】:
-
更改片段
android:layout_height="match_parent"并将您的按钮和 ImageView 放在 LinearLayout 上。 -
你知道What does TranslationZ actually do in Android?吗?删除
android:translationZ="1000dp"并尝试 -
@PratikButani OK 请等一下,我会试试。顺便说一句,感谢有关 TranslationZ 的信息。
-
@PratikButani 不过,ImageView 没有弹出。
-
@PratikButani 我必须将按钮和 Imageview 放入片段中吗?
标签: android xml android-layout