gpt4 book ai didi

android - 如何将拆分布局放在表格标题下方?

转载 作者:搜寻专家 更新时间:2023-11-01 09:30:51 25 4
gpt4 key购买 nike

我想在标题栏上方放置一个文本。但问题是,即使我放置了重量,我也无法将“Registrai 文本”与相应的标题栏对齐。

这是我试过的代码。

     <?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:isScrollContainer="false">

//this layout is not aligning properly with corresponding titles.

<LinearLayout
android:id="@+id/rel0"
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="14dp"
android:gravity="center_vertical"
android:weightSum="10">

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="2.5"
android:gravity="center"
android:text="14.30WIB"
android:textColor="@color/colorBlack"
android:textSize="14sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:gravity="center"
android:text="Sell in"
android:textColor="@color/colorBlack"
android:textSize="10sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="Sell in"
android:textColor="@color/colorBlack"
android:textSize="10sp" />

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Registrasi"
android:textColor="@color/colorBlack"
android:textSize="10sp" />

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

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="New"
android:textColor="@color/colorBlack"
android:textSize="10sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="Re"
android:textColor="@color/colorBlack"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>


<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="Edukasi"
android:textColor="@color/colorBlack"
android:textSize="8sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="POSM"
android:textColor="@color/colorBlack"
android:textSize="8sp" />

</LinearLayout>

<LinearLayout
android:id="@+id/rel1"
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_below="@+id/rel0"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="@drawable/nbd_title"
android:gravity="center_vertical"
android:weightSum="10">

<TextView
android:id="@+id/siteId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="2.5"
android:gravity="center"
android:text="Total"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/site"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:gravity="center"
android:text="XXXXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/twoG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/threeG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/fourG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/retailerId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

<TextView
android:id="@+id/idealId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textColor="@color/colorWhite"
android:textSize="12sp" />

</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

我的输出看起来像这样,没有与相应的标题正确对齐。

enter image description here

实际输出:(您可以在相应标题栏上方看到注册文本分成两部分的位置。但我无法使用它)

enter image description here

请指正我做错的地方。

最佳答案

您错误地使用了权重。在这里修复它。

<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:isScrollContainer="false">

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

<LinearLayout
android:id="@+id/rel0"
android:layout_width="match_parent"
android:layout_height="33dp"
android:gravity="center_vertical"
android:weightSum="10">

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="2.5"
android:gravity="center"
android:text="14.30WIB"
android:textSize="14sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:gravity="center"
android:text="Sell in"
android:textSize="10sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="Sell in"
android:textSize="10sp" />

<LinearLayout
android:layout_width="0dp"
android:layout_weight="2.4"
android:layout_height="wrap_content"
android:orientation="vertical">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Registrasi"
android:textSize="10sp" />

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

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="New"
android:textSize="10sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="Re"
android:textSize="10sp" />
</LinearLayout>
</LinearLayout>


<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="Edukasi"
android:textSize="8sp" />

<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="POSM"
android:textSize="8sp" />

</LinearLayout>

<LinearLayout
android:id="@+id/rel1"
android:layout_width="match_parent"
android:layout_height="33dp"
android:layout_below="@+id/rel0"
android:gravity="center_vertical"
android:weightSum="10">

<TextView
android:id="@+id/siteId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_weight="2.5"
android:gravity="center"
android:text="Total"
android:textSize="12sp" />

<TextView
android:id="@+id/site"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.5"
android:gravity="center"
android:text="XXXXX"
android:textSize="12sp" />

<TextView
android:id="@+id/twoG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textSize="12sp" />

<TextView
android:id="@+id/threeG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textSize="12sp" />

<TextView
android:id="@+id/fourG"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textSize="12sp" />

<TextView
android:id="@+id/retailerId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textSize="12sp" />

<TextView
android:id="@+id/idealId"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1.2"
android:gravity="center"
android:text="XXX"
android:textSize="12sp" />

</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>

关于android - 如何将拆分布局放在表格标题下方?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47572688/

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