gpt4 book ai didi

android - 两列,一列分成两行 - Android

转载 作者:行者123 更新时间:2023-11-30 02:04:39 26 4
gpt4 key购买 nike

我正在尝试实现一个 TableLayout,它有两列,第二列分为两行。像这样:

enter image description here

到目前为止,我所拥有的基本上是创建三列:

<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">

<TableRow
android:id="@+id/tr1"
android:layout_width="wrap_content"
android:layout_height="160dp"
>

<ImageView
android:src="@drawable/icon"
android:layout_span="1"
android:layout_height="160dp"
android:layout_width="200dp"
android:scaleType="centerCrop"
/>

<ImageView
android:src="@drawable/icon"
android:layout_height="75dp"
android:layout_width="wrap_content"
android:scaleType="centerCrop"
/>

<ImageView
android:src="@drawable/icon"
android:layout_height="75dp"
android:scaleType="centerCrop"
android:layout_width="wrap_content"/>

</TableRow>

</TableLayout>

最佳答案

您可以通过组合 LinearLayout 而不是 TableLayout 来实现:

<LinearLayout
android:layout_width="0dp"
android:layout_height="144dp"
android:layout_weight="0.5"
android:background="@android:color/holo_red_dark">

// Column A.
// Put your content here..

</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="144dp"
android:orientation="vertical"
android:weightSum="1"
android:layout_weight="0.5">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@android:color/holo_green_dark"
android:layout_weight="0.5">

// Column B, row 1.
// Put your content here..

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="72dp"
android:background="@android:color/holo_blue_dark"
android:layout_weight="0.5">

// Column B, row 2.
// Put your content here..

</LinearLayout>

</LinearLayout>

这是它将生成的布局:

enter image description here

关于android - 两列,一列分成两行 - Android,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30882243/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com