Can someone please tell me how to set the android:layout_weight and android:layout_width XML attributes in code for dynamically created views?
Reference: XML Table layout? Two EQUAL-width rows filled with equally width buttons?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Use ViewGroup.LayoutParams.
You can also specify fixed pixel sizes in the constructor, instead of the constants. But fixed pixels are a bad idea on android due to the variety of devices.
You can calculate the pixels from a
dpsize though, which is ok:(Here: convert 10dp to a pixel value)