0

üzerinde master demirlemeye sahip. Bir uygulamanın, tablet uygulamasında olduğu gibi bir tablette iki bölme gösterdiğinde ana bölüme sabitlenmesini sağlayan bir Kayan Eylem Düğmesi (FAB) istiyorum görüntü) ancak Android Studio'daki Ana/Detay şablonunu kullanarak bu işlevselliği kodlayamadı.Android Master/Ayrıntı - FAB, tek veya çok bölmeli

Varsayılan davranış, ekranın alt/sağ tarafındaki FAB ekranının hem tek hem de çok bölmeli modda olmasıdır.

FAB'yi faal_item_list.xml dosyasından RecyclerView öğesini içeren düzenlere taşımayı denedim, ancak bu çok bölmeli modda ayrıntı panelinin görüntülenmemesine neden oluyor.

FAB aynı zamanda master-detay şablonundan paftaları kullanarak master'a bağlı görüntülenebilir mi, yoksa sıfırdan başlamak ve belki de birden fazla parça ve aktivite kullanmak gerekli midir?

Showing FAB moving to be anchored to the list pane

Aşağıda şimdi FAB içeren item_list için değişmiş düzendir. İlk olarak şablonda olana göre bir RelativeLayout ve FAB ekledim.

<LinearLayout 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:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    android:baselineAligned="false" 
    android:divider="?android:attr/dividerHorizontal" 
    android:orientation="horizontal" 
    android:showDividers="middle" 
    tools:context=".ItemListActivity"> 

    <!-- This layout is a two-pane layout for the Items master/detail flow.--> 

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

     <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/item_list" 
      android:name=".ItemListFragment" 
      android:layout_width="@dimen/item_width" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="16dp" 
      app:layoutManager="LinearLayoutManager" 
      tools:context=".ItemListActivity" 
      tools:listitem="@layout/item_list_content" /> 

     <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:layout_alignParentRight="true" 
      android:layout_alignParentBottom="true" 
      android:src="@android:drawable/ic_dialog_email" /> 
    </RelativeLayout> 

    <FrameLayout 
     android:id="@+id/item_detail_container" 
     android:layout_width="0dp" 
     android:layout_height="match_parent" 
     android:layout_weight="3" /> 

</LinearLayout> 

cevap

0

Sorun, düzeniydi. 2. göreceli bir düzen eklenmesi ve detayın master'ın sağına yerleştirilmesi sorunu çözdü.

<LinearLayout 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:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    android:baselineAligned="false" 
    android:divider="?android:attr/dividerHorizontal" 
    android:orientation="horizontal" 
    android:showDividers="middle" 
    tools:context=".ItemListActivity"> 

    <!--This layout is a two-pane layout for the Items master/detail flow.--> 
    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent"> 

    <RelativeLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/item_list_master"> 

     <android.support.v7.widget.RecyclerView xmlns:android="http://schemas.android.com/apk/res/android" 
      xmlns:tools="http://schemas.android.com/tools" 
      android:id="@+id/item_list" 
      android:name=".ItemListFragment" 
      android:layout_width="@dimen/item_width" 
      android:layout_height="match_parent" 
      android:layout_marginLeft="16dp" 
      android:layout_marginRight="16dp" 
      app:layoutManager="LinearLayoutManager" 
      tools:context=".ItemListActivity" 
      tools:listitem="@layout/item_list_content" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_margin="@dimen/fab_margin" 
      android:layout_alignRight="@id/item_list" 
      android:src="@android:drawable/ic_dialog_email" /> 

    </RelativeLayout> 
     <FrameLayout 
      android:id="@+id/item_detail_container" 
      android:layout_width="400dp" 
      android:layout_height="match_parent" 
      android:layout_toRightOf="@+id/item_list_master" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" /> 

    </RelativeLayout> 
</LinearLayout> 
İlgili konular