【发布时间】:2019-09-20 21:01:24
【问题描述】:
将ImageView 或FrameLayout 放在Button 上时,我遇到了constraintlayout 的问题。
当我尝试在 FrameLayout 上填充 fragment 时,作为 Activity 一部分的按钮在片段 UI 顶部可见。
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="button"/>
<FrameLayout
android:background="@color/blue"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
</android.support.constraint.ConstraintLayout>
【问题讨论】:
-
看到这个答案stackoverflow.com/a/47987945/3286819 很可能你的
Button超过你的FrameLayout因为海拔。 -
嗨..你期待什么结果,你能指定吗?
-
其实这个框架布局并不是在按钮之上,而是占据了整个屏幕
-
我的意思是 FrameLayout 必须在按钮上方(应该屏蔽按钮)
-
我发现默认情况下按钮的高度是 2dp,所以我将 FrameLayout 提升到 4dp,我的问题就解决了
标签: android android-fragments android-constraintlayout