android:layout_marginbottom,有时CoordinatorLayout会切断marginBottom

activity_album_detail.xml H2>

xmlns:app="http://schemas.android.com/apk/res-auto"

android:id="@+id/main_content"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/fab_albumdetail"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="bottom"

android:layout_margin="@dimen/fab_margin" />

android:id="@+id/appbar_albumdetail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

android:id="@+id/collapsing_toolbar_albumdetail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

app:contentScrim="?attr/colorPrimary"

app:expandedTitleMarginEnd="25dp"

app:expandedTitleMarginStart="25dp"

app:layout_scrollFlags="scroll|exitUntilCollapsed">

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/backdrop_albumdetail"

android:layout_width="match_parent"

android:layout_height="370dp"

android:fitsSystemWindows="true"

android:scaleType="centerCrop"

android:transitionName="transition_album_detail"

app:layout_collapseMode="parallax" />

android:layout_alignParentBottom="true"

android:layout_width="match_parent"

android:layout_height="90dp"

android:background="@drawable/gradient" />

android:id="@+id/toolbar_albumdetail"

android:layout_width="match_parent"

android:layout_height="?attr/actionBarSize"

app:layout_collapseMode="pin"

app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />

app:layout_behavior="@string/appbar_scrolling_view_behavior"

android:layout_width="match_parent"

android:layout_height="match_parent">

android:id="@+id/cardview_albumdetail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_marginTop="16dp"

android:layout_marginBottom="100dp"

android:layout_marginStart="16dp"

android:layout_marginEnd="16dp">

android:id="@+id/recycler_album_detail"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:scrollbars="horizontal">

AlbumDetailActivity.java H1>

public class AlbumDetailActivity extends AppCompatActivity {

private long mAlbumID = -1;

private Album mAlbum = new Album();

private CollapsingToolbarLayout mCollapsingToolbar;

private AppBarLayout mAppBar;

private Toolbar mToolbar;

private ImageView mImageView;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_album_detail);

mAlbumID = getIntent().getLongExtra("album_id", -1);

mAlbum = AlbumLoader.getAlbum(getApplicationContext(), mAlbumID);

mCollapsingToolbar = findViewById(R.id.collapsing_toolbar_albumdetail);

mCollapsingToolbar.setTitle(mAlbum.albumTitle);

mAppBar = findViewById(R.id.appbar_albumdetail);

mImageView = findViewById(R.id.backdrop_albumdetail);

loadBackdrop();

setAdapter();

}

private void loadBackdrop() {

ImageLoader.getInstance().displayImage(AppUtils.getAlbumArtUri(mAlbumID).toString(), mImageView,

new DisplayImageOptions.Builder()

.resetViewBeforeLoading(true)

.cacheInMemory(true)

.cacheOnDisk(true)

.showImageOnFail(R.drawable.disc_black_512)

.showImageForEmptyUri(R.drawable.disc_black_128)

.build());

}

private void setAdapter() {

final RecyclerView list = findViewById(R.id.recycler_album_detail);

LinearLayoutManager manager = new LinearLayoutManager(getApplicationContext());

List songList = getSongsForAlbum(getApplicationContext(), mAlbumID);

SongAdapter adapter = new SongAdapter(getApplicationContext(), songList, false);

list.setLayoutManager(manager);

list.setAdapter(adapter);

}

SongAdapter.java H2>

public class SongAdapter extends HFRecyclerView implements RecyclerView.SectionedAdapter {

private List mList = new ArrayList<>();

private Context mContext;

private boolean mShouldShowCover;

public SongAdapter(Context cx, List songData, boolean cover) {

super(songData, false, false);

this.mList = songData;

this.mContext = cx;

this.mShouldShowCover = cover;

}

@Override

protected RecyclerView.ViewHolder getItemView(LayoutInflater inflater, ViewGroup parent) {

return new ItemViewHolder(inflater.inflate(R.layout.item_song, parent, false));

}

@Override

protected RecyclerView.ViewHolder getHeaderView(LayoutInflater inflater, ViewGroup parent) {

return null;

}

@Override

protected RecyclerView.ViewHolder getFooterView(LayoutInflater inflater, ViewGroup parent) {

return null;

//return new FooterViewHolder(inflater.inflate(R.layout.list_footer, parent, false));

}

@Override

public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {

if (holder instanceof ItemViewHolder) {

ItemViewHolder viewHolder = (ItemViewHolder) holder;

Song item = mList.get(position);

viewHolder.mTitle.setText(item.songTitle);

if (item.songArtist.equals("")) {

viewHolder.mAuthor.setText(mContext.getResources().getText(R.string.unknown_artist));

} else viewHolder.mAuthor.setText(item.songArtist);

viewHolder.mDuration.setText(item.songDuration);

DisplayImageOptions options = new DisplayImageOptions.Builder()

.cacheInMemory(true)

.cacheOnDisk(true)

.resetViewBeforeLoading(true)

.showImageOnLoading(R.drawable.compact_disc_128)

.showImageOnFail(R.drawable.compact_disc_128)

.build();

if (mShouldShowCover)

ImageLoader.getInstance().displayImage(AppUtils.getAlbumArtUri(item.songAlbumID).toString(), viewHolder.mCover, options);

}

}

private class ItemViewHolder extends RecyclerView.ViewHolder {

private TextView mTitle, mAuthor, mDuration;

private ImageView mCover;

private ItemViewHolder(View view) {

super(view);

mTitle = view.findViewById(R.id.track_title);

mAuthor = view.findViewById(R.id.track_artist);

mDuration = view.findViewById(R.id.track_lenght);

mCover = view.findViewById(R.id.track_cover);

}

}

private class FooterViewHolder extends RecyclerView.ViewHolder {

private FooterViewHolder(View view) {

super(view);

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值