2

因此,当我将内容包装在我的锁定可绘制对象上时,由于某种原因,可绘制对象在我定义的 TableLayout 中水平拉伸。我知道这不是图像本身,因为我已经在 LinearLayout 中对此进行了测试,并且图像显示完全正常。这是我的代码:

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

1 回答 1

0

一个可能的解决方案:

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

还有其他秤类型,测试它们直到它属于您的需要:

http://developer.android.com/reference/android/widget/ImageView.ScaleType.html

于 2013-07-23T21:55:47.877 回答