2013-07-23 36 views
2

因此,当我将内容封装在我的锁绘图上时,出于某种原因,drawable在我定义的TableLayout中水平伸展。我知道这不是图像本身,因为我已经在LinearLayout中测试过了,图像显示完全正常。这里是我的代码:ImageView在TableLayout中伸展

<?xml version="1.0" encoding="utf-8"?> 

<TableLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@drawable/metastatisticsscreen" 
    android:paddingTop="0dp" 
    > 
<TableRow 
    android:layout_height="wrap_content" 
    android:layout_width="fill_parent" 
    android:background="#45c9ff" 
    android:layout_marginBottom="3dp" 
    android:gravity="center_horizontal"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="@string/achievement" 
     android:textColor="#FFFFFF" 
     android:textSize="50sp" /> 

</TableRow> 


<TableRow 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:background="#FFFFFF"> 

    <ImageView 
     android:layout_height="wrap_content" 
     android:layout_width="wrap_content" 
     android:background="@drawable/lock"/> 

    <TextView 
     android:layout_height="wrap_content" 
     android:layout_width="fill_parent" 
     android:text="@string/additionachievement1descript"/> 

    </TableRow> 



</TableLayout> 

The problem is the lock drawable stretches itself horizontally. Any fix 
+0

变化'的android:layout_width =“fill_parent”'将'TableRows'设置为'android:layout_width =“wrap_content”'。 – Vikram

回答