美文网首页
Android中使用标签其他布局文件不显示

Android中使用标签其他布局文件不显示

作者: 临星hfuu | 来源:发表于2019-07-31 08:03 被阅读0次

最近在学习安卓,新人记录一下自己踩过的坑,方便自己以后查询。

事情是这样的,最近在跟着教程学习时遇到用  封装 NavigationBar;布局写好后在AndroidStudio中预览是正常的,但是在真机上运行时,除了封装的内容,其他布局都不显示。

引用的布局代码如下:

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

    xmlns:tools="http://schemas.android.com/tools"

    android:layout_width="match_parent"

    android:layout_height="wrap_content"

    xmlns:app="http://schemas.android.com/apk/res-auto"

    tools:orientation="vertical">

    <include layout="@layout/nav_bar"/>

    <ImageView

        android:layout_width="200dp"

        android:layout_height="200dp"

        android:src="@mipmap/logo"

        android:layout_gravity="center_horizontal"

        android:layout_marginTop="@dimen/marginSize"

        />

    <com.hu.j_music.views.InputView

        android:layout_width="match_parent"

        android:layout_height="wrap_content"

        app:input_icon="@mipmap/mine"

        app:input_hint="手机号"

        app:isPassWord="false">

    </com.hu.j_music.views.InputView>

</LinearLayout>

查了一下其他资料,发现也有人遇到这个问题,但是他说在标签下加上宽高属性就解决了,我试了一下还是没有解决我遇到的问题;

又仔细看了两遍上面的布局代码,发现是最外层LinearLayout布局的orientation属性是引用tools里的,可能是输入orientation时选择AS的提示输入内容时没有注意;

tools:orientation=“vertical”

改为

android:orientation=“vertical”

问题解决。

AS的提示代码确实很方便,但是使用的时候还是要注意一点,避免一不小心把自己带到坑里;

另外这个tools:下面的orientation属性也不知道是怎么回事,怎么使用什么情况下使用。改天有空查一下;

相关文章

网友评论

      本文标题:Android中使用标签其他布局文件不显示

      本文链接:https://www.haomeiwen.com/subject/juvarctx.html