horizontal recyclerview item width half of screen android

Solutions on MaxInterview for horizontal recyclerview item width half of screen android by the best coders in the world

showing results for - "horizontal recyclerview item width half of screen android"
Lisa
15 Jan 2018
1override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
2        val view = LayoutInflater.from(context).inflate(R.layout.row, parent, false);
3        view.layoutParams = ViewGroup.LayoutParams((parent.width * 0.5).toInt(),ViewGroup.LayoutParams.MATCH_PARENT)
4        return ViewHolder(view);
5    }
August
04 Aug 2016
1   @Override
2    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
3        View v = LayoutInflater.from(parent.getContext())
4                .inflate(R.layout.design_item, parent, false);
5        v.setLayoutParams(new ViewGroup.LayoutParams((int) (parent.getWidth() * 0.5),ViewGroup.LayoutParams.MATCH_PARENT));
6
7        return new ViewHolder(v);
8    }
similar questions