【问题标题】:Android XML tablerowAndroid XML 表格行
【发布时间】:2012-11-04 12:08:31
【问题描述】:

图片:www.gunzhaxplz.com/xmlAndroid.png my problem http://gunzhaxplz.com/xmlAndroid.png

前言:我正在制作一个需要在一个表格行上有 6 个图像的应用程序。

问题:我似乎无法调整大小的图像,右侧的最后一张图像超出了屏幕

这里是 XML:

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/TableLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal" >

<TableRow
    android:id="@+id/tableRow1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >




    <ImageButton
        android:id="@+id/imageButton1"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/golem_square" />





    <ImageButton
        android:id="@+id/imageButton2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/lizard_square" />




    <ImageButton
        android:id="@+id/imageButton3"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/baron_square" />



    <ImageButton
        android:id="@+id/imageButton4"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/dragon_square" />

</TableRow>

<TableRow
    android:id="@+id/tableRow2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" >

    <ImageButton
        android:id="@+id/ImageButton03"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/golem_square" />

    <ImageButton
        android:id="@+id/ImageButton01"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/lizard_square" />

    <ImageButton
        android:id="@+id/ImageButton02"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:src="@drawable/baron_square" />

    <ImageButton
        android:id="@+id/ImageButton04"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:src="@drawable/dragon_square" />
</TableRow>

【问题讨论】:

    标签: android android-layout


    【解决方案1】:

    尝试在每个 ImageButton 中设置以下参数

    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:adjustViewBounds="true"
    android:maxWidth="32dpi"
    android:maxHeight="32dpi"
    

    【讨论】:

    • 现在它们太小了,谢谢你我现在有办法玩这个了! :)
    • 如果要添加与表格行的相对布局,可以使用布局参数如:android:layout_toRightOf="@id/button1"
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-08-29
    • 1970-01-01
    • 2014-12-13
    • 1970-01-01
    • 1970-01-01
    • 2015-02-28
    • 1970-01-01
    相关资源
    最近更新 更多