[英]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.