2016-06-14 8 views
0

meine ListView gehen auf der Anwendungsleiste am Rand der Seite, ich habe wahrscheinlich ein Problem in der Layout-Datei. (Ich habe die Standard-Android-Studio-Aktivität verwendet, die Navigation Schublade, Anwendungsleiste, ...) Ich habe ein frameLayout verwendet, um es als Eltern zu Unteraktivität zu verwenden und zeigen Sie die Navigationsleiste in allen Unteraktivitäten.ListView überlappt Anwendungsleiste - Android

nav_header_main.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="@dimen/nav_header_height" 
    android:background="@drawable/side_nav_bar" 
    android:gravity="bottom" 
    android:orientation="vertical" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    android:theme="@style/ThemeOverlay.AppCompat.Dark"> 

    <ImageView 
     android:id="@+id/imageView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/nav_header_vertical_spacing" 
     android:src="@android:drawable/sym_def_app_icon" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:paddingTop="@dimen/nav_header_vertical_spacing" 
     android:text="MoviesInformer" 
     android:textAppearance="@style/TextAppearance.AppCompat.Body1" /> 

    <TextView 
     android:id="@+id/textView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="testing" /> 

content_main.xml

<RelativeLayout 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" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" 
    tools:context=".Activity.MainActivity" 
    tools:showIn="@layout/app_bar_main"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Movieys Informer" /> 
</RelativeLayout> 

app_bar_main.xml

<android.support.design.widget.CoordinatorLayout 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:fitsSystemWindows="true" 
    tools:context=".Activity.MainActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:theme="@style/AppTheme.AppBarOverlay"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:background="?attr/colorPrimary" 
      app:popupTheme="@style/AppTheme.PopupOverlay" /> 

    </android.support.design.widget.AppBarLayout> 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <!--<include layout="@layout/content_main" />--> 

</android.support.design.widget.CoordinatorLayout> 

activity_main.xml

<android.support.v4.widget.DrawerLayout 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:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    tools:openDrawer="start"> 

    <include 
     layout="@layout/app_bar_main" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <!--<FrameLayout--> 
     <!--android:id="@+id/content_frame"--> 
     <!--android:layout_width="match_parent"--> 
     <!--android:layout_height="match_parent" />--> 

    <android.support.design.widget.NavigationView 
     android:id="@+id/nav_view" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:layout_gravity="start" 
     android:fitsSystemWindows="true" 
     app:headerLayout="@layout/nav_header_main" 
     app:menu="@menu/activity_main_drawer" /> 


</android.support.v4.widget.DrawerLayout> 

cinema_activity.xml (die in der Unteraktivität verwendet wird)

<?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="wrap_content"> 

    <ListView 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:textAlignment="center" 
     android:clickable="true" 
     android:id="@+id/lwCinema" 
     /> 


</LinearLayout> 

kann mir bitte jemand helfen?

Repeat:

Listenansicht in der Subaktivität gehen auf der Oberseite der Anwendungsleiste (ich glaube, es heißt), aber es ist immer noch anklickbar. Ich muss es unter die App-Leiste setzen.

+0

set 'marginTop ="? Android: attr/actionBarSize "' in der Inhaltsansicht unter der Leiste –

+0

Ich verstehe nicht wo –

+0

Mögliche Duplikate von [Add Ansichten unter Symbolleiste in CoordinatorLayout] (http://stackoverflow.com/questions/ 32956071/add-views-unten-toolbar-in-coordinatorlayout) – Qw4z1

Antwort

1

Statt MarginTop verwenden = "android: attr/actionBarSize", ist der richtige Weg App hinzuzufügen: layout_behavior Attribut Ihr FrameLayout. Mit diesem Attribut wird das Rahmenlayout immer unterhalb der Symbolleiste positioniert.

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior" /> 

Und vergessen Sie nicht Xmlns hinzuzufügen: app = "http://schemas.android.com/apk/res-auto" Tag Wurzel des Layouts.

0

einfach ändern

<FrameLayout 
    android:id="@+id/content_frame" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" /> 

zu

<FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_marginTop="?android:attr/actionBarSize" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" />