Android:覆盖基本的高处视图,并制作一个扁平按钮

时间:2018-07-11 06:57:32

标签: android layout material-design

很抱歉基本问题,但我找不到解决方法:

当使用没有高程的布局覆盖按钮时,由于按钮具有一定的深度(负深度,它指向查看者),因此会出现在布局上方。

所以,如果您有一个

<FrameLayout... >
     <Button.../>
     <FrameLayout 
        id="@+id/fragmentsContainerOrAnything"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#C00F"
        android:clickable="true"
        android:focusable="true"
        >          
     </FrameLayout>
</FrameLayout>

该按钮将显示在FrameLayout上。...在这种情况下,因为按钮具有深度,所以实际上是“出乎意料”,因此即使将布局放置在“上方” “按钮。

问题是:

  1. 如何使FrameLayout覆盖基础Button而又不影响其高度。
  2. 如何使按钮变平?当然,我可以将其设置回原点并将其命名为“ TextView”。但是有更好的方法吗?

谢谢

1 个答案:

答案 0 :(得分:0)

在FrameLayout中添加按钮

<FrameLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <Button
            android:layout_width="match_parent"
            android:layout_height="wrap_content" />
    </FrameLayout>

    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#C00F"
        android:clickable="true"
        android:focusable="true" />
</FrameLayout>