android - 为什么TextView不显示?
问题描述
我的带有 TextView 的 LinearLayout 未在片段布局中显示。不显示带有 ImageView 的 LinearLayout 下的 Content。
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#fff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<!-- Other content -->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--
This TextView is not displayed
-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DUMMY"/>
</LinearLayout>
</ScrollView>
解决方案
使用ScrollView
时只能生一个孩子。
所以你的观点必须是这样的
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<!-- Your content -->
</LinearLayout>
</ScrollView>
你的内容在这里
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="20dp">
<!-- Other content -->
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--
This TextView is not displayed
-->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="DUMMY"/>
</LinearLayout>
推荐阅读
- php - 检查文本是否为表情符号的功能无法识别所有表情符号
- python - Python:代码在循环中的异常期间未运行
- aem - 在轮播中使用时,来自 DAM 资产的视频不会内联播放
- sql - 计算每日使用量的补充
- javascript - 如何将下拉列表值作为参数传递给函数
- android - 如何在 Google 的新 Places SDK 客户端中查询“findCurrentPlace”?我想添加自定义半径并输入搜索附近的地方
- powershell - 在 Powershell 中检索 system.object 基本类型的字符串值
- dart - 如何在打印功能中显示所有字符对象
- haskell - 使用类型类约束快速检查并报告生成的值?
- javascript - Angular 应用程序未在 IE 浏览器中打开,而应用程序在 Chrome 中打开