android - XML 布局不出现
问题描述
我正在编写一个 XML 代码,但它没有出现在布局上。怎么了?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/Number_Activity"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world"/>
</LinearLayout>
解决方案
这个xml文件没有问题,因为使用了不合适的主题看不到,修改styles.xml如下:
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> //use appropriate theme
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
推荐阅读
- python - 如何在列表格式的字典中获取结果
- javascript - 即使测试没有返回承诺,qunit 如何知道异步测试回调何时完成?
- java - 如何制作自动 twitter dm bot
- postgresql - 我们可以根据 changed_fields 列中的外键获取数据吗?
- curl - 使用 curl 在 HDInsight 中执行 Sqoop 不起作用
- unity3d - Unity - 设置变量的搜索脚本
- record - Ada 重叠标签字段
- facebook - 如何使用 Graph API 调用来调节 facebook 评论插件?
- python - 通过更改 XGBClassifier 的 random_state 来更改模型性能
- gitlab - 如何根据gitlab用户id获取gitlab用户名