Android 如何实现以下布局-在中间有一个固定高度视图,在顶部和底部有两个等高视图?

Android 如何实现以下布局-在中间有一个固定高度视图,在顶部和底部有两个等高视图?,android,layout,Android,Layout,如何在Android中实现以下垂直布局 View1 View2 View3 所有三个视图的宽度都适合屏幕 View2高度固定为100。 View1的高度等于view3的高度 我能通过线性布局、相对布局、约束布局来实现这一点吗 如果有一个编程解决方案,而不是XML布局,我将不胜感激 使用LinearLayout尝试此操作 输出 使用LinearLayout尝试此操作 输出 不确定这是你想要的,但你可以 减去View2的高度,只需将View1和View3的高度设置为结果的一半 您需要使用Relat

如何在Android中实现以下垂直布局

View1
View2
View3
所有三个视图的宽度都适合屏幕

View2高度固定为100。 View1的高度等于view3的高度

我能通过线性布局、相对布局、约束布局来实现这一点吗

如果有一个编程解决方案,而不是XML布局,我将不胜感激

使用LinearLayout尝试此操作

输出

使用LinearLayout尝试此操作

输出


不确定这是你想要的,但你可以

减去View2的高度,只需将View1和View3的高度设置为结果的一半


您需要使用RelativeLayout并根据需要对它们进行排序。

不确定这是您想要的,但您可以

减去View2的高度,只需将View1和View3的高度设置为结果的一半

您需要使用RelativeLayout并根据需要对它们进行排序。

我是否能够使用LinearLayout、RelativeLayout和ConstraintLayout实现这一点?。是的,通过使用所有这些工具,也通过使用TabLayout或GridLayout,您可以实现相同的结果。我是否能够使用LinearLayout、RelativeLayout、ConstraintLayout实现这一点?。是的,通过使用所有这些工具,也通过使用TabLayout或GridLayout,您可以获得相同的结果。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="match_parent"
    android:layout_height="match_parent">


    <View
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@color/colorAccent"/>
    <View
        android:layout_width="match_parent"
        android:layout_height="100dp"
        android:background="@color/colorDarkBlue"/>

    <View
        android:layout_width="match_parent"
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:background="@color/colorPrimary"/>

</LinearLayout>