簡體   English   中英

如何在Android表格布局中對齊微調框和textview?

[英]How to align spinner and textview in android table layout?

我正在使用文本視圖和微調器創建一個表布局。

我的textview內容太大,因此包裝在我的布局中。 每當textview換行時,同一行微調器也會增加高度。

我的代碼是

<TableRow 
            android:id="@+id/trConfigPeriodStop" 
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginTop="8dp"
            android:weightSum="1" >
            <TextView 
                android:id="@+id/tvConfigPeriodStop"
                android:text="Periodic reporting interval while moving"    
                android:layout_weight="0.5"           
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:textColor="@color/gpsblue"                      
                android:layout_marginLeft="5dp" />
            <Spinner 
                android:id="@+id/spnConfigPeriodStop"
                android:layout_weight="0.5"                
                android:layout_width="0dp"
                android:layout_height="fill_parent"
                android:entries="@array/periodstop_arrays"
                android:prompt="@string/periodstop_prompt"                                               
                />
        </TableRow>

假設我要在微調器的wrap_content中更改布局高度,那時候我的文本視圖文本也會從視圖中隱藏。

如何解決這個問題? 請只做那些需要的。 提前致謝。

嘗試將Spinner和TextView的布局高度都設置為wrap_content。

嘗試這個 :

<TableRow xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/trConfigPeriodStop"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"  
    android:textColor="@color/gpsblue"    
    android:weightSum="1" >

    <TextView
        android:id="@+id/tvConfigPeriodStop"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_marginLeft="5dp"
        android:layout_weight="0.5"
        android:text="Periodic reporting interval while moving" />

    <Spinner
        android:id="@+id/spnConfigPeriodStop"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:layout_weight="0.5"
        android:entries="@array/periodstop_arrays"
        android:prompt="@string/periodstop_prompt"  />

</TableRow>

我猜這是因為tablerow具有 android:layout_height =“ wrap_content”,而內部textview具有android:layout_height =“ fill_parent” ,所以tablerow的高度將適合微調器的高度,這是唯一具有固定且獨立的子項渲染時的高度。

如果將TextView的高度也更改為android,則將解決該問題:layout_height =“ wrap_content”

暫無
暫無

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

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