简体   繁体   English

Android:在屏幕上拟合ImageButtons表时出现问题

[英]Android: Problem fitting a table of ImageButtons within the screen

I am trying to create a table of 7 rows and 7 columns of ImageButtons - buttons with image resource added from the drawable folder. 我正在尝试创建一个7行和7列ImageButtons的表-具有从drawable文件夹添加的图像资源的按钮。 The problem is I can only see the first button and the rest go off screen. 问题是我只能看到第一个按钮,其余的都不显示在屏幕上。 How do I scale the image or the buttons so all 49 can be viewed on screen? 如何缩放图像或按钮,以便可以在屏幕上查看全部49个图像? The following is the main.xml file. 以下是main.xml文件。 Any help would be great!! 任何帮助将是巨大的! Thank you! 谢谢!

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

First, you do not need the android:layout_width="wrap_content" and android:layout_height="wrap_content" values for the children of TableRow . 首先,你不需要android:layout_width="wrap_content"android:layout_height="wrap_content"值的孩子TableRow

Also, try fitCenter instead of centerInside for your scaleType . 另外,为centerInside尝试使用fitCenter而不是scaleType

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM