简体   繁体   中英

How to align image button in android table layout?

I'm having the following 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>

My code looks like above example. Here my last table row having one image button. When I add this the background color also add this table row. so my page looks like the following image.

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

If you don't want the background color add these lines in your xml :

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

Or

android:background="?android:selectableItemBackground"

whats happen if u remove the attributes "layout_span" and "layout_weight" in the imageview declarition? I'm not sure, cause i haven't a ide with android sdk yet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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