Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

horizontal recyclerview item width half of screen android

   @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View v = LayoutInflater.from(parent.getContext())
                .inflate(R.layout.design_item, parent, false);
        v.setLayoutParams(new ViewGroup.LayoutParams((int) (parent.getWidth() * 0.5),ViewGroup.LayoutParams.MATCH_PARENT));

        return new ViewHolder(v);
    }
Comment

horizontal recyclerview item width half of screen android

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.row, parent, false);
        view.layoutParams = ViewGroup.LayoutParams((parent.width * 0.5).toInt(),ViewGroup.LayoutParams.MATCH_PARENT)
        return ViewHolder(view);
    }
Comment

PREVIOUS NEXT
Code Example
Java :: how to call a non static method 
Java :: java bogosort 
Java :: java scanner int to string 
Java :: https://www.baeldung.com/hibernate-inheritance 
Java :: Data provider using junit 
Java :: make quotation a string 
Java :: java integer division to float 
Java :: Unexpected end of file in android studio activity main.xml 
Java :: foreach skip to next java 
Java :: Java Create a LinkedHashSet 
Java :: what is static method in oop 
Java :: Add an element to ArrayList using addall() method 
Java :: could not load main class java 
Java :: check if input is empty java 
Java :: csv compare 
Java :: Java Access ConcurrentHashMap Elements 
Java :: get sum of array and return string 
Java :: marshalling in java 
Java :: copy text from header tag in javacript 
Java :: how to reverse numbers in java 
Java :: while loops java 
Java :: android bottomnav fab 
Java :: string array to string stream java 
Java :: java encapsulation 
Java :: what does setFocusable do in java 
Java :: android recyclerview pull to refresh 
Java :: Manual Custom Queries in spring boot 
Java :: java return pair 
Java :: java.sql.SQLSyntaxErrorException: Unknown column 
Java :: Exception handling using try...catch 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =