2016-05-23 18 views
3

私のアプリは、ViewPagerで1つのアクティビティを使用して、アプリページのフラグメントを交換します。他のフラグメントはすべて動作しますが、なんらかの理由でそれらのうちの1つ、私の設定フラグメントは動作しません。次の図はこれを示しています。赤い部分は不要なマージンです。青色の領域は、主なアクティビティレイアウトで定義されたツールバーです。常に存在します。緑豊かなエリアは、メインアクティビティのレイアウトで定義された主なViewPager、次のとおりです。レイアウト全体に奇妙なマージン

enter image description here

これはMainActivityレイアウトは次のようになります。

<RelativeLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/main_layout" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".activities.MainActivity" 
android:fitsSystemWindows="true" > 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <!-- Tab Bar --> 
    <com.rentalapp.rentmi.views.SlidingTabLayout 
     android:id="@+id/main_content_pager_tab_bar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/toolbar" 
     android:background="@color/primary" /> 

    <!-- Content Pager --> 
    <android.support.v4.view.ViewPager 
     android:id="@+id/main_content_pager" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/main_content_pager_tab_bar" /> 

</RelativeLayout> 

</RelativeLayout> 

そして、これは設定の断片は、次のようになります:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Settings" 
     android:id="@+id/textView2" 
     android:layout_alignParentTop="true" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="10dp" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Log Out" 
     android:id="@+id/logout" 
     android:layout_below="@+id/textView2" 
     android:layout_centerHorizontal="true" 
     android:paddingTop="10dp" /> 

</RelativeLayout> 

どのようにこの不要なマージンを修正しますか?メインレイアウトからandroid:fitsSystemWindows="true"を削除すると、他の1ページおきにタブバーの上に表示される通知バーが表示されますが、これは必要ありません。

+0

私はそれがステータスバーの高さだと思います。 ? ' – convexHull

+0

は、あなたが「アンドロイド:paddingTopは=」削除しようとしましたfitsSystemWindows =「true」を: 'アンドロイドでプレイしてみます。のTextView内10dpを」とのマージンを使用して –

+0

@FranklinHirataええ、私はそれらと混乱している – Dooskington

答えて

8

わかりませんが、私が持っていたandroid:fitsSystemWindows="true"を削除して修正できました。過去にそれを取り除くことはすべてを破った。今それはそれを修正しました。

+0

、非常に奇妙なindeed.butが動作しますありがとうございます:D – mohnage7

関連する問題