2016-05-01 13 views
0

私は自分のアプリでリストビューを実装しています。私はアンドロイド6.0のための私のアプリを構築しようとしているテーマ "DarkActionBar"を選択しました。今私はこのコードをactivity_main.xmlに持っています。Androidの要素と重なっているツールバー

<?xml version="1.0" encoding="utf-8"?> 
<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="com.mycompany.www.mynotes.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> 

    <ListView 
     android:id="@+id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 
    </ListView> 

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

このコードでは、リストビュー(テキストビューを置き換える)を追加しました。私のプロジェクトを作成したとき、残りのコードは既にそこにありました。

今、私はリストビューにランダムにいくつかの項目を追加しています。 問題は、リストビューの一番上の項目が、の画像に示すようにツールバーの後ろにあることです。それを修正するには?このリストビューをツールバーの下から開始します。

enter image description here

+0

この質問は、としなければならない何Androidスタジオ? Android StudioはAndroid開発用のIDEです。問題はIDEに依存しません。 – chRyNaN

答えて

1

を:

<ListView 
     android:id="@+id/android:list" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     app:layout_behavior="@string/appbar_scrolling_view_behavior"/> 
+0

ありがとう、それは動作します。しかし、このappbar_scrolling_view_behaviorはどこから来たのか教えてください。このようなリソースはstrings.xmlにありません。 –

関連する問題