繁体   English   中英

如何在android表格布局中对齐图像按钮?

[英]How to align image button in android table layout?

我有以下表格布局。

<TableLayout 
android:id="@+id/tlImpEventContent"
android:layout_width="fill_parent" 
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_span="1"                     
android:stretchColumns="*" >    
<TableRow 
    android:id="@+id/trStatusCode" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:weightSum="1" >
    <TextView 
        android:id="@+id/tvStatusCode"
        android:text="@string/statuscode"    
        android:layout_weight="0.5"           
        style="@style/ContentTextViewValue" 
        android:textColor="@color/gpsblue"                      
        android:layout_marginLeft="5dp" />
    <TextView 
        android:id="@+id/tvStatusCodeAns"
        android:layout_weight="0.5"                
        style="@style/ContentTextViewValue" 
        android:text="@string/app_name"                          
        />
</TableRow>
<TableRow 
    android:id="@+id/trMsg" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:weightSum="1" >
    <TextView 
        android:id="@+id/tvMsg"
        android:text="@string/message"    
        android:layout_span="1"
        android:layout_weight="1"           
        style="@style/ContentTextViewValue" 
        android:textColor="@color/gpsblue"                      
        android:layout_marginLeft="5dp" />                          
</TableRow> 
<TableRow 
    android:id="@+id/trMsgAns" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:weightSum="1" >
    <EditText
        android:id="@+id/tvMsgAns"
        android:inputType="textMultiLine" 
        android:lines="5" 
        android:minLines="5" 
        android:gravity="top|left" 
        android:layout_span="1"
        android:maxLines="10"                       
        android:scrollbars="vertical"
        android:layout_weight="1"   
        style="@style/ContentTextViewValue" 
        android:layout_marginLeft="5dp"
        />
</TableRow>

<TableRow 
    android:id="@+id/trSend" 
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_marginTop="8dp"
    android:weightSum="1" >
    <ImageButton 
        android:id="@+id/ivSend"
        android:src="@drawable/gts_send"
        android:contentDescription="@string/send"     
        android:layout_weight="1"       
        android:layout_span="1"    
        style="@style/ContentTextViewValue" 
        android:textColor="@color/gpsblue"
        android:textStyle="bold"                    
        android:layout_marginLeft="5dp" />
</TableRow>

我的代码看起来像上面的例子。 这里我的最后一个表行有一个图像按钮。 当我添加此背景颜色时,也会添加此表格行。 所以我的页面看起来像下面的图像。

我想删除这个突出显示的背景颜色。我应该怎么做?请只做那些需要的。提前致谢

如果您不想要背景颜色,请在xml中添加以下行:

android:layout_width="wrap_content"
android:layout_height="wrap_content"

要么

android:background="?android:selectableItemBackground"

如果您在imageview声明中删除属性“layout_span”和“layout_weight”,会发生什么? 我不确定,因为我还没有使用android sdk的ide

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM