Lavanya
Lavanya

Reputation: 621

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.

I want to remove this highlighted background color. How should I do? Please do the needful. Thanks in advance

Upvotes: 0

Views: 1258

Answers (2)

Manu Zi
Manu Zi

Reputation: 2370

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

Upvotes: 0

Pull
Pull

Reputation: 2246

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"

Upvotes: 2

Related Questions