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
變化'的android:layout_width =「fill_parent」'將'TableRows'設置爲'android:layout_width =「wrap_content」'。 – Vikram