Reputation: 61
I want to know that:
Can layouts be designed or edited in an Activity(.java) class
If yes then how? Any one champion here who can guide me?
Upvotes: 0
Views: 179
Reputation: 364
Yes you can.. You have to create a LayOut class and give parameters like this.
LinearLayout ll=new LinearLayout(MainActivity.this);
ll.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView('your View here');
Upvotes: 1
Reputation: 44571
Can layouts be designed or edited in an Activity(.java) class
Yes, but doing so through xml is generally easier
If yes then how?
By using the properties you find in the layout docs. You can look up tutorials or specific questions on SO but no one can go through every step of how to write a layout for you. Have a look in the different docs such as the RelativeLayout docs it has all the properties and methods that can be accessed through Java as well as their xml counterparts.
As I said, you can do it in Java but designing layouts through xml is generally much easier.
Upvotes: 0