簡體   English   中英

Android動態列表視圖對齊

[英]Android dynamic list-view alignment

我對Android布局有一個問題,我正在嘗試在警報對話框中創建動態列表視圖。 如下

Column1                 Column2                   Column3                  Column4
hjdgfhdbfhjnb        hjdjhfjkhkjnhjkln                 dhjfjdkh                  hdjghjd
hgchg676          kjkcvkjv                 hjchjcc                 cjjkcjclkjnn

這正在發生,但我想以完全一致的方式進行。 我正在使用此功能,但不適用於我

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="4" >

  <TextView
            android:id="@+id/orderTitle"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/black_gradient"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/search_batchnumber"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1.5"
            android:textColor="@color/black_gradient"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/search_inventory"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight=".5"
            android:textColor="@color/black_gradient"
            android:textSize="20dp" />

        <TextView
            android:id="@+id/search_rate"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:textColor="@color/black_gradient"
            android:textSize="20dp" />

     </LinearLayout>

所以請給我建議,我該怎么做?

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    android:weightSum="4" >

    <TextView
        android:id="@+id/orderTitle"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="left"
        android:textColor="@color/black_gradient"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/search_batchnumber"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1.5"
        android:gravity="left"
        android:textColor="@color/black_gradient"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/search_inventory"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight=".5"
        android:gravity="left"
        android:textColor="@color/black_gradient"
        android:textSize="20dp" />

    <TextView
        android:id="@+id/search_rate"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:gravity="left"
        android:textColor="@color/black_gradient"
        android:textSize="20dp" />

</LinearLayout>

try this.

將linearLayout寬度更改為android:layout_width =“ match_parent”

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM