首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Android: tablerow消失了?

Android: tablerow消失了?
EN

Stack Overflow用户
提问于 2011-06-17 08:30:24
回答 2查看 1K关注 0票数 0

我有一个带有两个<TableRow><TableLayout>,第一行包含两个按钮(这很好用),第二行包含一个包含<ImageView><FrameLayout>。我的问题是,直到我将图像加载到ImageView中,第二个TableRow (和FrameLayout)才会出现。我希望FrameLayout始终可见(具有其背景颜色)。

我在<ImageView><FrameLayout>中使用了android:layout_width="match_parent"android:layout_height="match_parent",但似乎没有什么帮助。

下面是布局xml:

代码语言:javascript
复制
<TableLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingTop="5dp"
    android:stretchColumns="1">
    <TableRow>
        <Button
            android:id="@+id/buttonLoadPhoto"
            android:text="Load..."
            android:textSize="20sp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
        <Button
            android:id="@+id/buttonPrintPhoto"
            android:text="Print..."
            android:textSize="20sp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </TableRow>
    <TableRow
        android:background="#FF4422">
        <FrameLayout
            android:id="@+id/frameLayoutPhoto"
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:background="#303030">
            <ImageView
                android:id="@+id/imageViewPhoto"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:scaleType="matrix">
            </ImageView>
        </FrameLayout>
    </TableRow>
</TableLayout>

注意1:我为有问题的<TableRow>添加了一个背景色,这样我就可以将问题缩小到TableRow而不是ImageView (TableRow的背景色没有显示出来)。

注2:这是加载到<TabHost><FrameLayout>中的Activity的布局,以防万一。

注3:我的目标是Android2.2,我正在使用Xoom进行测试。

从本质上讲,我希望<FrameLayout>占据选项卡中的剩余空间。有没有其他方法可以做到这一点?

谢谢!

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-06-18 00:36:33

我找到了使用<LinearLayout>s的替代解决方案:

代码语言:javascript
复制
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    android:paddingTop="5dp">
    <LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <Button
            android:id="@+id/buttonLoadPhoto"
            android:text="Load..."
            android:textSize="20sp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
        <Button
            android:id="@+id/buttonPrintPhoto"
            android:text="Print..."
            android:textSize="20sp"
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1" />
    </LinearLayout>
    <FrameLayout
        android:id="@+id/frameLayoutPhoto"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="#303030">
        <ImageView
            android:id="@+id/imageViewPhoto"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:scaleType="matrix">
        </ImageView>
    </FrameLayout>
</LinearLayout>
票数 0
EN

Stack Overflow用户

发布于 2011-06-17 08:50:35

documentation声明layout_height应该是WRAP_CONTENT,宽度应该是MATCH_PARENT,并且您不需要指定它们,因为它无论如何都会强制执行它们。我不确定您是否在尝试调试时添加了这些内容。

编辑(此行不正确,但仍保留在注释中提到的高度):您也可以尝试设置TableRow的高度,因为没有提供任何内容,并且其中的内容在图像出现之前没有高度。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6380176

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档