如何实现这种布局设计,其中视图位于另一个视图之上

阴极

我必须编码 a layout,其中视图与另一个视图重叠。在设计中,当我点击时,bt1 Linearlayout我们会在bt1带有小动画的正下方看到除了上一想到怎么把我设计布局的动画,一切都LinearLayoutbt3bt4

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background">

<TableLayout
    android:id="@+id/lv1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/custom_toolbar"
    android:layout_marginTop="5dp"
    android:orientation="horizontal">

    <TableRow>

        <Button
            android:id="@+id/bt1"
            android:layout_width="0dp"
            android:layout_height="35dp"
            android:layout_marginEnd="2.5dp"
            android:layout_marginStart="3dp"
            android:layout_weight="1"
            android:background="@color/darkgrey"
            android:fontFamily="@font/brandon_re"
            android:text="button1"
            android:textColor="@color/defaultWhite"
            android:textSize="15dp" />

        <Button
            android:id="@+id/bt2"
            android:layout_width="0dp"
            android:layout_height="35dp"
            android:layout_marginEnd="3dp"
            android:layout_marginStart="2.5dp"
            android:layout_weight="1"
            android:background="@color/darkgrey"
            android:fontFamily="@font/brandon_re"
            android:text="button2"
            android:textColor="@color/defaultWhite"
            android:textSize="15dp" />
    </TableRow>
</TableLayout>

<LinearLayout
    android:id="@+id/lv2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignTop="@+id/lv1"
    android:layout_alignBottom="@+id/lv1">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="130dp"

        />
</LinearLayout>

<Button
    android:id="@+id/bt3"
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:layout_marginEnd="3dp"
    android:layout_marginStart="2.5dp"
    android:layout_weight="1"
    android:background="@color/darkgrey"
    android:fontFamily="@font/brandon_re"
    android:layout_below="@+id/lv1"
    android:layout_marginTop="20dp"
    android:text="button3"
    android:textColor="@color/defaultWhite"
    android:textSize="15dp" />
<Button
    android:id="@+id/bt4"
    android:layout_width="match_parent"
    android:layout_height="35dp"
    android:layout_marginEnd="3dp"
    android:layout_marginStart="2.5dp"
    android:layout_weight="1"
    android:background="@color/darkgrey"
    android:fontFamily="@font/brandon_re"
    android:layout_below="@+id/bt3"
    android:layout_marginTop="20dp"
    android:text="button4"
    android:textColor="@color/defaultWhite"
    android:textSize="15dp" />
</RelativeLayout>
穆罕默德·莫海丁 AH

使用相对布局的 layout_below 属性。

将您的线性布局代码更改为按钮代码之后并在一个布局中添加按钮。

<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    >
... 
/* buttons */

</RelativeLayout>     

<LinearLayout
        android:id="@+id/lv2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/lv1">

        <TextView
            android:layout_width="match_parent"
            android:layout_height="130dp"

            />
    </LinearLayout>

完整代码

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

    <TableLayout
        android:id="@+id/lv1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginTop="5dp"
        android:orientation="horizontal">

        <TableRow>

            <Button
                android:id="@+id/bt1"
                android:layout_width="0dp"
                android:layout_height="35dp"
                android:layout_marginEnd="2.5dp"
                android:layout_marginStart="3dp"
                android:layout_marginLeft="3dp"
                android:layout_marginRight="2.5dp"
                android:layout_weight="1"
                android:text="button1"
                android:textSize="15dp" />

            <Button
                android:id="@+id/bt2"
                android:layout_width="0dp"
                android:layout_height="35dp"
                android:layout_marginEnd="3dp"
                android:layout_marginStart="2.5dp"
                android:layout_marginLeft="3dp"
                android:layout_marginRight="2.5dp"
                android:layout_weight="1"
                android:text="button2"
                android:textSize="15dp" />
        </TableRow>
    </TableLayout>


<RelativeLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    >

    <Button
        android:id="@+id/bt3"
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:layout_marginEnd="3dp"
        android:layout_marginStart="2.5dp"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="2.5dp"
        android:layout_weight="1"
        android:layout_marginTop="20dp"
        android:text="button3"
        android:textSize="15dp" />

    <Button
        android:id="@+id/bt4"
        android:layout_width="match_parent"
        android:layout_height="35dp"
        android:layout_marginEnd="3dp"
        android:layout_marginStart="2.5dp"
        android:layout_marginLeft="3dp"
        android:layout_marginRight="2.5dp"
        android:layout_weight="1"
        android:layout_below="@+id/bt3"
        android:layout_marginTop="20dp"
        android:text="button4"
        android:textSize="15dp" />

</RelativeLayout>

<LinearLayout
    android:id="@+id/lv2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@android:color/white"
    >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="130dp"

        />
</LinearLayout>

</RelativeLayout>

您必须使用重叠布局的背景才能看到重叠..

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在不弄乱自动布局的情况下由另一个视图占据一个视图位置

来自分类Dev

引导行在html中的移动视图中位于另一个之上

来自分类Dev

相对于另一个视图的约束布局切换视图位置

来自分类Dev

Android:如何创建EditText并将其设置为另一个视图位置?

来自分类Dev

Android如果一个视图位于FrameLayout中另一个视图的顶部,并且是不可见的,它会拦截单击/触摸事件吗?

来自分类Dev

如何在同一活动中的另一个视图之上显示一个视图

来自分类Dev

如何在同一活动中的另一个视图之上显示一个视图

来自分类Dev

创建一个布局,其中视图固定在ImageView的底部(但也堆叠在顶部)

来自分类Dev

如何在表格视图单元格中获取文本字段文本,该表格视图位于 swift 4 中的另一个表格视图控制器中?

来自分类Dev

如何实现对一个视图拖动到另一个视图上的检测?

来自分类Dev

如何将2个视图放置到父视图的底部,但一个视图堆叠在另一个视图之上?

来自分类Dev

如何从包含合并标记的布局访问另一个布局中的视图?

来自分类Dev

如何从另一个视图创建视图?

来自分类Dev

如何在另一个布局之上添加布局?

来自分类Dev

如何使固定元素位于另一个位置固定元素之上

来自分类Dev

如何使React组件位于另一个组件之上

来自分类Dev

对多个视图进行动画处理,其中一个视图先于另一个视图完成

来自分类Dev

ScrollView在另一个布局Android之上

来自分类Dev

将布局放在另一个之上

来自分类Dev

如何基于Android中该视图的坐标来知道一个视图何时在另一视图之上

来自分类Dev

如何在MvvmCross的另一个视图中实现SplitView?

来自分类Dev

如何在线性布局(另一个线性布局的子级)中均匀分布视图?

来自分类Dev

如何获取图像视图的clickevent,但是imageview在另一个布局中作为当前布局的标题

来自分类Dev

如何在线性布局(另一个线性布局的子级)中均匀分布视图?

来自分类Dev

如何将图像视图传递到另一个布局并将其保存在布局中?

来自分类Dev

在线性布局中将一个文本视图与另一个对齐

来自分类Dev

如何将视图放置在另一个视图的顶部,并且两个视图的中心在约束布局中对齐?

来自分类Dev

以编程方式在另一个布局之上添加一个布局

来自分类Dev

Android以编程方式将布局视图添加到另一个布局

Related 相关文章

  1. 1

    如何在不弄乱自动布局的情况下由另一个视图占据一个视图位置

  2. 2

    引导行在html中的移动视图中位于另一个之上

  3. 3

    相对于另一个视图的约束布局切换视图位置

  4. 4

    Android:如何创建EditText并将其设置为另一个视图位置?

  5. 5

    Android如果一个视图位于FrameLayout中另一个视图的顶部,并且是不可见的,它会拦截单击/触摸事件吗?

  6. 6

    如何在同一活动中的另一个视图之上显示一个视图

  7. 7

    如何在同一活动中的另一个视图之上显示一个视图

  8. 8

    创建一个布局,其中视图固定在ImageView的底部(但也堆叠在顶部)

  9. 9

    如何在表格视图单元格中获取文本字段文本,该表格视图位于 swift 4 中的另一个表格视图控制器中?

  10. 10

    如何实现对一个视图拖动到另一个视图上的检测?

  11. 11

    如何将2个视图放置到父视图的底部,但一个视图堆叠在另一个视图之上?

  12. 12

    如何从包含合并标记的布局访问另一个布局中的视图?

  13. 13

    如何从另一个视图创建视图?

  14. 14

    如何在另一个布局之上添加布局?

  15. 15

    如何使固定元素位于另一个位置固定元素之上

  16. 16

    如何使React组件位于另一个组件之上

  17. 17

    对多个视图进行动画处理,其中一个视图先于另一个视图完成

  18. 18

    ScrollView在另一个布局Android之上

  19. 19

    将布局放在另一个之上

  20. 20

    如何基于Android中该视图的坐标来知道一个视图何时在另一视图之上

  21. 21

    如何在MvvmCross的另一个视图中实现SplitView?

  22. 22

    如何在线性布局(另一个线性布局的子级)中均匀分布视图?

  23. 23

    如何获取图像视图的clickevent,但是imageview在另一个布局中作为当前布局的标题

  24. 24

    如何在线性布局(另一个线性布局的子级)中均匀分布视图?

  25. 25

    如何将图像视图传递到另一个布局并将其保存在布局中?

  26. 26

    在线性布局中将一个文本视图与另一个对齐

  27. 27

    如何将视图放置在另一个视图的顶部,并且两个视图的中心在约束布局中对齐?

  28. 28

    以编程方式在另一个布局之上添加一个布局

  29. 29

    Android以编程方式将布局视图添加到另一个布局

热门标签

归档