gpt4 book ai didi

android - 在它们之间有分隔线的 TextView

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:23:40 25 4
gpt4 key购买 nike

我正在尝试在 android studio 中重新创建以下布局:

Preview image

因为我在 android 方面还是个新手,所以我首先尝试使用 LinearLayout,并认为这可能无法实现。现在我正在尝试使用 RelativeLayout 我已经用颜色创建了这个 block :

        <RelativeLayout
android:layout_width="fill_parent"
android:layout_height="80dp"
android:background="@color/red_top">
</RelativeLayout>

现在我想问一下如何在同一布局中将其划分为如图所示的顶部 1 栏和底部 2 栏,以及如何放置相同的边框?

最佳答案

您可以使用以下 xml 代码执行此操作:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/custom_toast_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CD96CD"
android:text="TEXT" />

<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#000000" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:background="#CD96CD"
android:text="TEXT" />

<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#000000" />

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:background="#CD96CD"
android:text="TEXT" />
</LinearLayout>

</LinearLayout>

关于android - 在它们之间有分隔线的 TextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18444913/

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