繁体   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