1
我試圖用8個不同的框(2 colums * 4 rows)進行網格佈局。不幸的是,每當我嘗試加載一個圖像時,它都會出現bug和loades圖像的放大版本。這是我的代碼。必須注意的是工作得很好,當我剛剛加載一些寫作Xamarin android grid並不是在添加背景圖像時縮放單元格
首先,它看起來是這樣的: Without background image
用下面的代碼:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:background="@drawable/garage">
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/background_dark" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/background_light" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/holo_green_dark" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/holo_orange_dark" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/holo_purple" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/holo_orange_light" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/holo_red_light" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@android:color/darker_gray" />
</GridLayout>
我嘗試添加背景圖片後在細胞中的一個,這是我所得到的:Only one cell that takes up more space than the whole screen as it looks
具有以下代碼:
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2"
android:background="@drawable/garage">
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1"
android:background="@drawable/spaceshuttle1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
<TextView
android:layout_columnWeight="1"
android:layout_rowWeight="1" />
</GridLayout>
我該怎麼做,讓圖像留在它的細胞?