2017-03-29 29 views
-2

Im在Visual Studio中構建一個Android應用程序。在我的feed.axml文件中,我的主體內容在標題欄上方浮動。它應該在標題欄下方。我很困惑,爲什麼我的代碼是這樣做的。Android應用程序的主要內容是以上標題欄

my android app as of this post 此圖片中顯示的內容位於標題欄上方,爲卡片和大文本。如果有人知道如何將這些元素浮在標題欄下方,請告訴我。

任何幫助,將不勝感激

這裏是我的XML代碼:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<android.support.v4.widget.DrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_height="match_parent" 
    android:layout_width="fill_parent" 
    android:fitsSystemWindows="true"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     <android.support.v7.widget.CardView 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/cardView1" /> 
     <TextView 
      android:text="hello world" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView1" /> 
     <include 
      layout="@layout/toolbar" /> 
    </LinearLayout> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_height="match_parent" 
     android:layout_width="300dp" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header" /> 
</android.support.v4.widget.DrawerLayout> 

+1

在什麼地方啄你有''和''工具欄''在垂直上市之前'<的LinearLayout>'。如果你想讓它們在下面,把它們移到它之後。 –

回答

1

與此

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent"> 
<include 
    layout="@layout/toolbar" /> 
<android.support.v4.widget.DrawerLayout xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/drawer_layout" 
    android:layout_height="match_parent" 
    android:layout_width="fill_parent" 
    android:fitsSystemWindows="true"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     <android.support.v7.widget.CardView 
      android:minWidth="25px" 
      android:minHeight="25px" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/cardView1" /> 
     <TextView 
      android:text="hello world" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:id="@+id/textView1" /> 

    </LinearLayout> 
    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_height="match_parent" 
     android:layout_width="300dp" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header" /> 
</android.support.v4.widget.DrawerLayout> 

的LinearLayout放置其子線性替換你的代碼,所以你需要做這樣的事情。 您也可以將您的工具欄CardView

+0

非常感謝Ashish非常感謝。 – jack

相關問題