Android 将TableLayout 和LinearLayout 一起添加?

标签 android layout imageview tablelayout

我有一个基本的 LinearLayout,里面有 TableLayout 和 ImageView,我想将表格放在顶部,然后将图片放在底部中心,我该如何解决这个问题? 星期四,我在 Java 代码中将所有行添加到 TableLayout 中,因此希望在代码中看到。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent"
app:showAsAction="ifRoom">

<TableLayout
    android:id="@+id/Table"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:stretchColumns="1"
    android:shrinkColumns="0">
</TableLayout>

<!--<LinearLayout-->
    <!--android:layout_gravity="bottom"-->
    <!--android:id="@+id/secLayout"-->
    <!--android:orientation="vertical"-->
    <!--android:layout_width="wrap_content"-->
    <!--android:layout_height="wrap_content">-->

    <ImageView
        android:id="@+id/pic1"
        android:src="@mipmap/pic1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ImageView>

<!--</LinearLayout>-->

有什么想法吗?

最佳答案

请检查我的解决方案

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    app:showAsAction="ifRoom"  // remove it
    >
    <TableLayout
        android:id="@+id/Table"
        android:layout_width="match_parent"
        android:layout_height="0dp" // change it
        android:layout_weight = 1 // add it
        android:stretchColumns="1"
        android:shrinkColumns="0">
    </TableLayout>

    <ImageView
        android:id="@+id/pic1"
        android:src="@mipmap/pic1"
        android:layout_gravity="center"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content">
    </ImageView>

</LinearLayout>

希望这有帮助

关于Android 将TableLayout 和LinearLayout 一起添加?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32837466/

相关文章:

android - 将 ImageView ScaleType 设置为 "center"无法正常工作

android - 批量选择位图/ImageViews android

Android:点击时生成随机颜色?

android - Applozic ConversationActivity 到 fragment

android 更改底部栏中的默认项目

Android 11 用户无法授予后台位置权限?

swift - “UICollectionView 必须使用非零布局参数初始化”?

jQuery 同位素不适用于我的布局

android - 我什么时候应该将图像保存到数据库