Android中使用標簽其他布局文件不顯示

最近在學習安卓,新人記錄一下自己踩過的坑,方便自己以后查詢。

事情是這樣的,最近在跟著教程學習時遇到用? 封裝 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>

查了一下其他資料,發(fā)現(xiàn)也有人遇到這個問題,但是他說在標簽下加上寬高屬性就解決了,我試了一下還是沒有解決我遇到的問題;

又仔細看了兩遍上面的布局代碼,發(fā)現(xiàn)是最外層LinearLayout布局的orientation屬性是引用tools里的,可能是輸入orientation時選擇AS的提示輸入內容時沒有注意;

tools:orientation=“vertical”

改為

android:orientation=“vertical”

問題解決。

AS的提示代碼確實很方便,但是使用的時候還是要注意一點,避免一不小心把自己帶到坑里;

另外這個tools:下面的orientation屬性也不知道是怎么回事,怎么使用什么情況下使用。改天有空查一下;

?著作權歸作者所有,轉載或內容合作請聯(lián)系作者
【社區(qū)內容提示】社區(qū)部分內容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發(fā)布,文章內容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內容

友情鏈接更多精彩內容