I have Activity which contains list of words inside RecyclerView. By clicking on "Play" menu button user starts the player which can voice all words from list and manipulates them like simple music player. The player is made from fragment.The result I want to achieve. Currently my own Activity looks like that. Here I have 2 issues which I can't fix: 1) Fragment doesn't overlap recyclerView correctly. 2) Fragment buttons are not clickable. When I try to interact with a player, first list's item is being clicked constantly.
To achieve overlapping and clickability I tried to play with android:alpha and focusable attributes but it didn't bring any effect. Code of fragment's click listener has already been written. Below I post necessary activity's xml and java code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include
android:id="@+id/toolbar_words"
layout="@layout/layout_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<!--Container for PlayerFragment-->
<FrameLayout
android:id="@+id/player_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<android.support.v7.widget.RecyclerView
android:id="@+id/words_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
The code from Activity to create PlayerFragment
@Override
public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.action_player:
initPlayer();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void initPlayer() {
PlayerFragment mPlayerFragment = new PlayerFragment();
FragmentManager mFragmentManager = getSupportFragmentManager();
FragmentTransaction mFragmentTransaction = mFragmentManager.beginTransaction();
mFragmentTransaction.add(R.id.player_container, mPlayerFragment, PLAYER_FRAGMENT);
mFragmentTransaction.commit();
}
答案 0 :(得分:0)
尝试下面的Recyclerview代码。
<android.support.v7.widget.RecyclerView
android:id="@+id/words_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/player_container"/>