2013-11-27 186 views
0

我有以下表格布局。如何在Android桌面布局中对齐图像按钮?

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

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

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

+0

张贴您的xml文件: – Piyush

回答

2

如果你不希望的背景颜色在你的XML添加这些行:

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

或者

android:background="?android:selectableItemBackground" 
+0

仍然我有同样的问题。 – Lavanya

+0

android:background = @ android:color/transparent不起作用? – Pull

+0

错误是我的。我已经改变了图像视图,而不是图像按钮问题已经解决。谢谢.... – Lavanya

0

什么如果u删除属性发生 “layout_span”和“layout_weight”在图像查看器中显示?我不知道,因为我还没有与Android SDK的ide

+0

什么都没有发生。每当我使用带图像按钮的表格行时,我的设计就会发生同样的问题。 – Lavanya

+1

我已经解决了这个问题,使用imageview而不是图像按钮。 – Lavanya