[英]Android: Problem fitting a table of ImageButtons within the screen
我正在嘗試創建一個7行和7列ImageButtons的表-具有從drawable文件夾添加的圖像資源的按鈕。 問題是我只能看到第一個按鈕,其余的都不顯示在屏幕上。 如何縮放圖像或按鈕,以便可以在屏幕上查看全部49個圖像? 以下是main.xml文件。 任何幫助將是巨大的! 謝謝!
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow>
<ImageButton
android:id="@+id/r0c0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/frog"
android:scaleType="centerInside"
/>
<ImageButton
android:id="@+id/r0c1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/frog"
android:scaleType="centerInside"
/>
<!-- 5 more ImageButtons go here -->
</TableRow>
<TableRow>
<ImageButton
android:id="@+id/r1c0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/frog"
android:scaleType="centerInside"
/>
<ImageButton
android:id="@+id/r1c1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/frog"
android:scaleType="centerInside"
/>
<!-- 5 more ImageButtons go here -->
</TableRow>
<!-- 5 more TableRows go here -->
</TableLayout>
首先,你不需要android:layout_width="wrap_content"
和android:layout_height="wrap_content"
值的孩子TableRow
。
另外,為centerInside
嘗試使用fitCenter
而不是scaleType
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.