2016-06-16 9 views
0

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.rt.giftcard.ScrollingActivity"> 
 

 
    <android.support.design.widget.AppBarLayout 
 
     android:id="@+id/app_bar" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="@dimen/app_bar_height" 
 
     android:fitsSystemWindows="true" 
 
     android:theme="@style/AppTheme.AppBarOverlay"> 
 

 
     <android.support.design.widget.CollapsingToolbarLayout 
 
      android:id="@+id/toolbar_layout" 
 
      android:layout_width="match_parent" 
 
      android:layout_height="match_parent" 
 
      android:fitsSystemWindows="true" 
 
      app:contentScrim="?attr/colorPrimary" 
 
      app:layout_scrollFlags="scroll|exitUntilCollapsed" 
 
      android:background="@color/material_deep_teal_500"> 
 

 
      <android.support.v7.widget.Toolbar 
 
       android:id="@+id/toolbar" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="?attr/actionBarSize" 
 
       app:layout_collapseMode="pin" 
 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 
 

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

 

 
    <include layout="@layout/content_scrolling" 
 
     android:id="@+id/page_content" /> 
 

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

私は最初のレイアウトを変更しようとしたかもしれないフラグメントが解決されているが、私はどのように知らない? が含まれますか

答えて

0

はい、あなたは間違いなくインクルードの代わりにフラグメントを使用したいと思っています。あなたはフラグメントhereについてもっと読むことができますが、それはあなたが取る必要があるいくつかの手順です。

1)<include>タグを<fragment>タグに置き換えます。名前とIDを含む属性を定義します。

2)Fragmentクラスを定義します。 <fragment>タグの名前は、Fragmentから継承するクラスを参照する必要があります。フラグメントは典型的なアクティビティに似ていますので、学習曲線はそれほど悪くはありません。

3)親アクティビティで、現在の画面にフラグメントを追加するFragmentTransactionを作成するために、FragmentManagerのインスタンスを取得します。それは多くのように聞こえる、私は知っているが、誰かがそれを簡単に説明しているhere

私は役立つことを願っています。あなたがフラグメントを作ることに慣れると、これは簡単に行えるはずです。

+0

非常にありがとう。私はそれを試してみる、それは働いているように感じる:) – Tavak

+0

驚くばかり、正しい場合は、答えをマークすることができますか?ありがとう、相棒。 – arjabbar

関連する問題