0

하나의 주 활동 및 일부 조각으로 된 응용 프로그램이 있습니다. 모든 조각은 목록 조각이지만, 일부에서는 사용자 지정 동작이있는 FloatingActionButton을 추가해야합니다. 그 목록에 자동 생성 어댑터를 보존하고 싶습니다. FloatingActionButton을 xml list disapper에 직접 추가하면 어떻게 단추를 추가 할 수 있습니까? 조각 목록의 목록 뷰 아래에 부동 단추 추가

내 조각 XML 코드

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.RecyclerView 
    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:id="@+id/list" 
    android:name="it.ivannotarstefano.cojule.activity.PlayerFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    app:layoutManager="LinearLayoutManager" 
    tools:context="it.ivannotarstefano.cojule.activity.PlayerFragment" 
    tools:listitem="@layout/fragment_player" > 

</android.support.v7.widget.RecyclerView> 

내가 이런 식으로

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v7.widget.RecyclerView 
    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:id="@+id/list" 
    android:name="it.ivannotarstefano.cojule.activity.PlayerFragment" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_marginLeft="16dp" 
    android:layout_marginRight="16dp" 
    app:layoutManager="LinearLayoutManager" 
    tools:context="it.ivannotarstefano.cojule.activity.PlayerFragment" 
    tools:listitem="@layout/fragment_player" > 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/floatingActionButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="10dp" 
     android:clickable="true" 
     android:focusable="true" 
     android:src="@drawable/ic_add_black_24dp" 
     app:backgroundTint="#fff700" /> 

</android.support.v7.widget.RecyclerView> 

답변

1
<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    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:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:id="@+id/list" 
     android:name="it.ivannotarstefano.cojule.activity.PlayerFragment" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_marginLeft="16dp" 
     android:layout_marginRight="16dp" 
     app:layoutManager="LinearLayoutManager" /> 

    <android.support.design.widget.FloatingActionButton 
     android:id="@+id/floatingActionButton" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="bottom|end" 
     android:layout_margin="10dp" 
     android:baselineAlignBottom="true" 
     android:clickable="true" 
     android:focusable="true" 
     android:src="@drawable/side_nav_bar" 
     app:backgroundTint="#fff700" /> 

</FrameLayout> 
에 FloatingActionButton를 추가하는 시도