【问题标题】:How to set recyclerview last item to the bottom of navigation drawer in android如何在android中将recyclerview最后一项设置到导航抽屉的底部
【发布时间】:2015-11-19 20:04:40
【问题描述】:

我正在使用recyclerview 作为导航抽屉。我需要放置最后一项以对齐导航抽屉的底部。我怎样才能做到这一点。我已经尝试过在项目装饰中使用偏移量。它适用于我的手机,但我使用了硬编码值作为偏移量。我怎样才能动态地做到这一点。请帮我解决一下这个。 这是物品装饰的代码

    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {

        int itemPosition = parent.getChildAdapterPosition(view);

        if(itemPosition == 2){
            int height = parent.getMeasuredHeight();
            int viewHeight = view.getMeasuredHeight();
            outRect.top = parent.getHeight()/2 + 230;
            view.setBackground(context.getResources().getDrawable(R.drawable.drawer_border_top));
        }

   }

} 

【问题讨论】:

    标签: android android-recyclerview navigation-drawer


    【解决方案1】:
    LinearLayoutManager llm = (new LinearLayoutManager(context);
    llm.setOrientation(LinearLayoutManager.VERTICAL);
    llm.setReverseLayout(true);
    recList.setLayoutManager(llm);
    

    【讨论】:

    • 如果您知道如何在列表大小不适合空间的情况下将最后一项设置在底部,这将很有帮助
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多