2014-12-26 2 views
0

все мои макеты находятся поверх моего ActionBar. Это похоже на очень простой вопрос, но я не могу понять, как это понять.Выпуск макета Android в верхней части actionBar

enter image description here

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:paddingTop="?android:attr/actionBarSize" 
    android:fitsSystemWindows="true" > 

    <TextView 
     android:id="@+id/txtLabel" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="16dp" 
     android:text="Home View" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentStart="true" /> 

    <ImageView android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@id/txtLabel" 
     android:src="@drawable/ic_home" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="10dp" 
     android:id="@+id/imageView" /> 

    <Button 
     android:layout_width="fill_parent" 
     android:layout_height="40dp" 
     android:text="Logout" 
     android:id="@+id/logout" 
     android:textSize="13dp" 
     android:textColor="#000000" 
     android:layout_marginLeft="0dp" 
     android:layout_below="@+id/imageView" 
     android:layout_alignParentStart="true" /> 

</RelativeLayout> 

Любые идеи?

Благодаря

+0

android: fitsSystemWindows = "true" вы можете удалить его? –

+0

Я удалил его, но ничего не изменилось ... – Dan

ответ

0

Проблема решаемая: DI изменить ActionBar на панель инструментов https://stackoverflow.com/a/26700904/4394523:

это теперь мой themes.xml

<resources> 
    <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> 
     <item name="colorPrimary">@color/colorPrimary</item> 
     <item name="colorPrimaryDark">@color/colorPrimary_dark</item> 
     <item name="colorAccent">@color/colorAccent</item> 
     <item name="android:windowNoTitle">true</item> 
     <item name="windowActionBar">false</item> 
    </style> 
</resources> 

toolbar.xml

<android.support.v7.widget.Toolbar 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:id="@+id/toolbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="?attr/colorPrimary" 
    android:minHeight="?attr/actionBarSize" 
    app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" 
    app:popupTheme="@style/ThemeOverlay.AppCompat.Light"> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="" 
     android:textAppearance="@android:style/TextAppearance.Theme" 
     android:textColor="@android:color/white" /> 
</android.support.v7.widget.Toolbar> 

и поместить это в макете :

android:layout_marginTop="?attr/actionBarSize" 
Смежные вопросы