Is it possible to use Java code to write to the main.xml file?
I want to make some changes to the layout but have it based from values received from Java?
Is it possible to use Java code to write to the main.xml file? I
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.
Yes you can. Read more about YOURLAYOUT.LayoutParams
http://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html
Use the
addRule()and specify what you need to your layout object.Change the values before you do
setContentView();Something like:
Or if you want to make changes on the actual layout from the xml then you do the inflating