我使用RelativeLayout制作了一个带有以下代码的XML: 我看不到带有ID“TV_voucher_number”的TextView。 我试过让XML成为一个scrollview,但后来我无法正确看到ListView。 代码:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.ManageYourTrip.mytguideapp.Voucher" >
<LinearLayout
android:id="@+id/voucherTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Voucher"
android:textColor="@color/Black"
android:textSize="24sp"
android:textStyle="bold"/>
</LinearLayout>
<TextView
android:id="@+id/TV_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/voucherTitle"
android:text="Date: "
android:textSize="12sp"
android:textStyle="bold"
android:textColor="@color/Black"
>
</TextView>
<TextView
android:id="@+id/TV_voucher_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/TV_Date"
android:layout_below="@id/voucherTitle"
android:textColor="@color/Black"
android:textSize="12sp">
</TextView>
<TextView
android:id="@+id/TV_supplier_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/TV_Date"
android:text="Supplier Details:"
android:textColor="@color/Black"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/TV_supplier_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TV_supplier_title"
android:textColor="@color/Black"
android:textSize="12dp">
</TextView>
<TextView
android:id="@+id/LI_TV_suppliers_Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TV_supplier_name"
android:textColor="@color/Black"
android:textSize="12dp">
</TextView>
<TextView
android:id="@+id/TV_products_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/LI_TV_suppliers_Address"
android:text="PRODUCTS"
android:textColor="@color/Black"
android:textSize="12dp"
android:textStyle="bold"
android:layout_marginLeft="2dp">
</TextView>
<TextView
android:id="@+id/TV_products_quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/LI_TV_suppliers_Address"
android:text="Qty."
android:textColor="@color/Black"
android:textSize="12dp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
</TextView>
<ListView
android:id="@+id/ProductsList"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_below="@id/TV_products_title">
</ListView>
<TextView
android:id="@+id/voucher_number"
android:layout_marginTop="20dp"
android:layout_below="@id/ProductsList"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textColor="@color/Black"
android:text="VOUCHER #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/TV_voucher_number"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_below="@id/voucher_number"
android:textColor="@color/Black"
android:textSize="12dp">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_below="@id/ProductsList"
android:layout_marginTop="20dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:textColor="@color/Black"
android:text="REF #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
</RelativeLayout>
答案 0 :(得分:0)
实际上,您已将android:layout_height="match_parent"
设置为ProductsList
,覆盖TV_voucher_number
高度。这可能是个问题。
希望这有帮助。
<强>更新强>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.ManageYourTrip.mytguideapp.Voucher" >
<LinearLayout
android:id="@+id/voucherTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Voucher"
android:textColor="@color/buttons_bg"
android:textSize="24sp"
android:textStyle="bold"/>
</LinearLayout>
<TextView
android:id="@+id/TV_Date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/voucherTitle"
android:text="Date: "
android:textSize="12sp"
android:textStyle="bold"
android:textColor="@color/buttons_bg"
>
</TextView>
<TextView
android:id="@+id/TV_voucher_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_toRightOf="@id/TV_Date"
android:layout_below="@id/voucherTitle"
android:textColor="@color/buttons_bg"
android:textSize="12sp">
</TextView>
<TextView
android:id="@+id/TV_supplier_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/TV_Date"
android:text="Supplier Details:"
android:textColor="@color/buttons_bg"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/TV_supplier_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TV_supplier_title"
android:textColor="@color/buttons_bg"
android:textSize="12dp">
</TextView>
<TextView
android:id="@+id/LI_TV_suppliers_Address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/TV_supplier_name"
android:textColor="@color/buttons_bg"
android:textSize="12dp">
</TextView>
<TextView
android:id="@+id/TV_products_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/LI_TV_suppliers_Address"
android:text="PRODUCTS"
android:textColor="@color/buttons_bg"
android:textSize="12dp"
android:textStyle="bold"
android:layout_marginLeft="2dp">
</TextView>
<TextView
android:id="@+id/TV_products_quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@id/LI_TV_suppliers_Address"
android:text="Qty."
android:textColor="@color/buttons_bg"
android:textSize="12dp"
android:textStyle="bold"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true">
</TextView>
<LinearLayout
android:id="@+id/ll_ListView"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/TV_products_title"
android:weightSum="3">
<ListView
android:id="@+id/ProductsList"
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="2"
>
</ListView>
<TextView
android:id="@+id/voucher_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/buttons_bg"
android:layout_below="@id/ProductsList"
android:text="VOUCHER #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/TV_voucher_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ll_ListView"
android:textColor="@color/buttons_bg"
android:text="Hello Wrord"
android:textSize="12dp">
</TextView>
<TextView
android:id="@+id/tv_Ref"
android:layout_width="wrap_content"
android:layout_below="@id/TV_voucher_number"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textColor="@color/row_body_background_even"
android:text="REF #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
</LinearLayout>
</RelativeLayout>
答案 1 :(得分:0)
尝试将最后3个textview放在相对布局中,如下所示:
<RelativeLayout
android:id="@+id/hello"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/ProductsList">
<TextView
android:id="@+id/voucher_number"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VOUCHER #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/TV_voucher_number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/voucher_number"
android:text="HELLO"
android:textSize="12dp">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_below="@id/TV_voucher_number"
android:layout_marginTop="20dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:text="REF #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
</RelativeLayout>
答案 2 :(得分:0)
试试这个:
print bulk_order_id
1 523
2 528
3 527
4 573
Name: order_id, dtype: object
print cluster_6_loc
1 Cluster 1
2 Cluster 2
3 Cluster 3
4 Cluster 4
Name: Clusters, dtype: object
cluster_final = pd.concat([bulk_order_id, cluster_6_loc], axis=1).set_index('Clusters')
#reset index name
cluster_final.index.name = ''
print cluster_final.ix[:,0]
Cluster 1 523
Cluster 2 528
Cluster 3 527
Cluster 4 573
Name: order_id, dtype: object
基本上你只需要将listview设置在bottom_layout之上,并将你的bottom_layout设置为alightParentBottom。希望这是你想要的;)
答案 3 :(得分:0)
将此TextView
的高度更改为wrap_content,如下所示:
<TextView
android:id="@+id/voucher_number"
android:layout_marginTop="20dp"
android:layout_below="@id/ProductsList"
android:layout_width="wrap_content"
android:layout_height="wrap_content" //THIS GUY
android:text="VOUCHER #"
android:textSize="12dp"
android:textStyle="bold">
</TextView>
当然会将文字设为TV_voucher_number
。
工作正常