2016-03-10 1 views
0

Я добавил по умолчанию Toolbar в моем текущем приложении.ToolBar перекрывает мой RelativeLayout, когда я использую по умолчанию toolBar в android

Но когда я добавил этот инструментBar, мой «Hello world» textview не появляется.

Как решить эту проблему !?

activity_main.xml: -

<?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.example.venkat.actionbarapp.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.v7.widget.Toolbar> 

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

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

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      android:layout_margin="@dimen/fab_margin" 
      android:src="@android:drawable/ic_dialog_email" /> 

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

content_main.xml: -

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:background="@android:color/holo_blue_dark" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/toolbar" 
     android:layout_marginTop="10dp"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:textColor="@android:color/holo_red_dark" 
      android:layout_height="wrap_content" 
      android:text="Hello World!" /> 

    </RelativeLayout> 

ответ

2

Попробуйте это -

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     android:background="@android:color/holo_blue_dark" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginTop="10dp" 

     app:layout_behavior="@string/appbar_scrolling_view_behavior" > 

     <TextView 
      android:layout_width="wrap_content" 
      android:textColor="@android:color/holo_red_dark" 
      android:layout_height="wrap_content" 
      android:text="Hello World!" /> 

    </RelativeLayout> 
+0

да теперь отлично работает как шарм, спасибо большое – AbhiRam

0

Это может помочь (в activity_main.xml)

<include layout="@layout/content_main" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/toolbar"/> 

и удалить андроид: layout_below = "@ + идентификатор/панель инструментов"
от content_main.xml

ИЛИ

добавить ниже 2 строки в content_main.xml

xmlns:tools="http://schemas.android.com/tools" 
tools:showIn="@layout/activity_main" 

и удалить андроид: layout_below =» @ + идентификатор/панель»

+0

no not working still my helloworld label не отображается – AbhiRam

+0

добавить ниже 2 строки в content_main.xml xmlns: tools = "http://schemas.android.com/tools" tools: showIn = "@ layout/activity_main" and remove android: layout_below = "@ + id/toolbar" –