我的目的是做一个带有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. AcWing 853. 有边数限制的最短路 bellman-ford 结构体

    //存在负权值 处理负环 //如果能求出来 一般是不存在负权回路 //如果有负回路 那最小距离可能是负无穷 #include <cstring> #include <iostream ...

  2. AcWing 240. 食物链

    #include <iostream> using namespace std; ; int n, m; int p[N], d[N]; //p是baba,d是距离 int find(in ...

  3. Atcoder Beginner Contest151E(排列组合)

    排列组合 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ; ]; long lo ...

  4. awk基本介绍

    AWK 是一种用于处理文本的编程语言工具.awk经过改进生成的新的版本nawk,gawk,现在默认linux系统下日常使用的是gawk,用命令可以查看正在应用的awk的来源(ls -l /bin/aw ...

  5. springboot+mybatis报错Invalid bound statement (not found)

    今天做项目时报了一个错提示说Invalid bound statement (not found),也就是说mapper接口绑定.xml文件出错了,找不到指定的sql:原因是程序没有把.xml文件编译 ...

  6. 前端开发CSS清除浮动的方法有哪些?

    在前端开发过程中,非IE浏览器下,当容器的高度自动,并且容器内容中有浮动元素(float为left或right),此时如果容器的高度不能自适应内容的高度,从而使得内容溢出破坏整体布局,这种现象叫做浮动 ...

  7. 攻防世界 misc Exercise 刷题记录

    1.base64stego 1.zip伪加密 2. base64文件隐写,在网上找一个脚本

  8. springboot 注解@EnableConfigurationProperties @ConfigurationProperties作用

    @EnableConfigurationProperties 在springboot启动类添加,当springboot程序启动时会立即加载@EnableConfigurationProperties注 ...

  9. 技术学习的网站 http://www.runoob.com/

    菜鸟教程:http://www.runoob.com/ W3C:https://www.w3cschool.cn/tutorial 脚本之家:https://www.jb51.net/

  10. tp5 配置 // 视图输出字符串内容替换 'view_replace_str' 的原理