2016-08-07 13 views
0

私はナビゲーションドローヤーを使用していますが、フラグメントに何かを入れるたびに、アクションバーはレイアウトを尊重しません。アプリテーマ(アクションバー)があなたのスペースを尊重していない

画像自体は説明:

enter image description here

fragment_main:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.leonel.picollo.MainFragment"> 

<Button 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="MAIN" 
    android:padding="8dp" 
    android:textColor="#fff" 
    android:background="@color/colorPrimary" 
    android:textSize="28sp" 
    android:id="@+id/textView" 
    android:layout_centerHorizontal="true" 
    android:layout_centerVertical="true" 
/> 

</RelativeLayout> 

そしてMainFragment.java:

package com.example.leonel.picollo; 


import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 


public class MainFragment extends Fragment { 


public MainFragment() { 
    // Required empty public constructor 
} 


@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    return inflater.inflate(R.layout.fragment_main, container, false); 
} 

}

+0

私たちに見せることができる(XML)コードはありますか? – Nathan

+0

もちろん、どのクラスですか? –

+0

Tasso Guimareas fragment_main.xmlとMainFragment.classも役に立ちます。 – Nathan

答えて

1

カスタムツールバーの使用にはいくつかの影響があります。カスタムツールバーは高さを持ち、他の要素はデフォルトでそれを尊重しないので、パディングやマージンを設定する必要があります。 RelativeLayout marginに追加ツールバーの高さを上にします。

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:marginTop="?attr/actionBarSize" <!-- here is marginTop --> 
tools:context="com.example.leonel.picollo.MainFragment"> 
</RelativeLayout> 
+0

私はあなたの答えに感謝しました! –

関連する問題