我的目的是做一个带有TextView的ListView列表页面。

以下是这个页面的xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <include
layout="@layout/head"/> <GridView
android:id="@+id/gv_home"
android:numColumns="3"
android:layout_width="match_parent"
android:layout_height="match_parent" /> </LinearLayout>

以下是这个页面的head.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" > <TextView
android:id="@+id/tv_head"
android:text="@string/loading"
android:textSize="22sp"
android:background="@color/bg_color"
android:textColor="#000000"
android:layout_width="match_parent"
android:gravity="center"
android:layout_height="55dip"/> </RelativeLayout>

可以看到我设置了head.xml宽高都是match_parent,而不给Include设定宽高,那么相当于给Include设定了match_parent,这样导致下面的ListView被挤到屏幕下面了。

导致ListView  GridView的内容不显示。

解决办法:

1. 给Include设定高度为wrap_content

2. 给head.xml的RelativeLayout设定高度为wrap_content

Android开发遇到的问题:不给include设置width、height,导致ListView GridView内容无法显示的更多相关文章

  1. Android开发中Eclipse里的智能提示设置

    今天开始学习一下Android开发,直接在Android Developers下载的一个开发工具包,然后再下了一个JDK,配置完环境变量等一系列的工作后环境就搭建好了,在新建好第一个Android项目 ...

  2. Android开发 静态static类与static方法持有Context是否导致内存泄露的疑问

    简述 在Android开发的过程中,难免会使用单例模式或者静态方法工具类.我们会让它们持有一些外部的Context或者View一般有以下几种情况: 单例模式,类的全局变量持有Context 或 Vie ...

  3. Android开发(十一)——ImageView的尺寸设置scaleType

    ImageView的属性android:scaleType,即 ImageView.setScaleType(ImageView.ScaleType). android:scaleType是控制图片如 ...

  4. Android开发网上的一些重要知识点[经验分享]

    1. android单实例运行方法 我们都知道Android平台没有任务管理器,而内部App维护者一个Activity history stack来实现窗口显示和销毁,对于常规从快捷方式运行来看都是s ...

  5. android开发中fragment获取context

    在用到fragment时无法使用.this来指定当前context内容,android开发中fragment获取context,可以使用getActivity().getApplicationCont ...

  6. 【Mood-12】Android开发相关书籍推荐

    新年伊始,找到Android进阶干货若干,2015拜读. 1.Android应用UI设计模式 目前,谷歌Android操作系统在移动市场中风头正劲,并且未来发展势不可挡.<Android应用UI ...

  7. 关于android开发添加菜单XML文件之后无法在R.java中生成ID的问题

    因为和同学分开做的android软件,现在想整合他做的界面部分,于是拷贝了res和src文件夹的文件,其中包括一个res.menu文件夹中的XML.但是每次将该文件导入到工程总无法自动在R.java中 ...

  8. 【视频】零基础学Android开发:蓝牙聊天室APP(四)

    零基础学Android开发:蓝牙聊天室APP第四讲 4.1 ListView控件的使用 4.2 BaseAdapter具体解释 4.3 ListView分布与滚动事件 4.4 ListView事件监听 ...

  9. Android开发——Notification通知的使用及NotificationCopat.Builder常用设置API

    想要看全部设置的请看这一篇 [转]NotificationCopat.Builder全部设置 常用设置: 设置属性 说明 setAutoCancel(boolean autocancel) 设置点击信 ...

随机推荐

  1. Mongodb学习笔记(四)管理

    一.数据导出.导入 数据导入:mongoexport ./mongoimport -d 数据库 -c 集合 文件名 数据导出:mongoimport 参数说明: -d:指明使用的库,如text -c: ...

  2. React的React.createElement源码解析(一)

    一.什么是jsx  jsx是语法糖  它是js和html的组合使用  二.为什么用jsx语法 高效定义模版,编译后使用 不会带来性能问题 三.jsx语法转化为js语法  jsx语法通过babel转化为 ...

  3. mtrace 简介

    内存泄露问题一般会再长时间运行的程序中暴露出来.而且一般很难定位和查找. linux 提供mtrace/muntrace来检测程序是否有内存泄露.一般来说要检测哪一段代码是否有内存泄露,就可以用这一对 ...

  4. 解决vim选中文字不能复制的问题

    转载自本人独立博客:https://liushiming.cn/2020/01/18/vim-copy-issue-in-iterm2/ 概述 最近发现在iterm2中打开vim,用鼠标选中文字,并用 ...

  5. 8.5-Day1T1--Asm.Def 谈笑风生

    题目大意 m个操作, 1:添加一个字符串 2:查询字符串s是否被添加过(中至多包含一个通配符“*”) 题解 trie树可以得部分分 用map映射 '*'就枚举26个英文字母来判断就可以了 #inclu ...

  6. Plastic Bottle Manufacturer -Composition And Process Of Plastic Bottles

    Plastic bottles are mainly made of materials such as polyethylene or polypropylene and adding a vari ...

  7. acm数论之旅--唯一分解定理

    题目: 给出n,问n = b^p中p符合该等式的最大值 分析: 先求出所有n的质因子,然后对这m个质因子分类统计,比如 n = 36时,可以分成 2个2,2个3,然后求出所有这些基数的 最大公因数gc ...

  8. Solr 8.2.0最新RCE漏洞复现

    漏洞描述 国外安全研究员s00py公开了一个Apache Solr的Velocity模板注入漏洞.该漏洞可以攻击最新版本的Solr. 漏洞编号 无 影响范围 包括但不限于8.2.0(20191031最 ...

  9. 安装Linux系统后配置的一般步骤

    安装linux后配置的一般步骤 最近在尝试不同的linux系统,记录一下安装完linux之后常用的软件的安装方法 1.源的更新 ubuntu 源的更新方法 参考(没有测试过,但是都大同小异,不行就换一 ...

  10. 在linux下安装java(centos和ubuntu)

    在本地测试环境安装插件,发现还得用到java,虽说是个程序员,可是没用过java啊,哎,但是插件得用啊,怎么办啊?自己装呗 一.自己的系统:CentOS 7 1.查看CentOS自带JDK是否已安装. ...