If I’m creating RelativeLayout of my own in code (not in XML) and wish to set its various attributes (android:layout_centerVertical, etc) what is the syntax for doing this?
Share
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.
I think you need to use
LayoutParams. This should help you out:You need to create the
LayoutParamsobject and then useaddRule()to add rules to it. Then you just set the parameters to theViewyou want. Be careful when importingLayoutParamsbecause there are different imports for different types ofView. I think you’ll want the one calledRelativeLayout.LayoutParamsHere is a link to the dev guide for extra help