Linear Layout in android kotlin | LinearLayout kotlin android | Kotlin tutorial for beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys welcome to my channel today in this video tutorial we are going to learn about linear layout in android so the language we are using in this tutorial series is scotland so let's start so in our previous tutorial we have uh learnt about constraint layout so and this is our designer if i go to its code which is xml so i'll remove this constraint layout and i'll make this a linear layout so linear layout this one and i'll make a space and now if i go to design we see nothing here if i come again here now this is constrained out so i have to remove this as well and make this linear layout now the error is gone now if i go to design and now if i drag in a button here now you can see a button here and now if i go to code you can see a button here as well now i'll go to design again and i'll drag in another button now you can see another button is added but it is added horizontally now if i add in a third one so it will horizontally add into this now this is horizontally added because the orientation of this non-linear layout this one at the top which is our parent layout this one is uh horizontal by default if i make this uh orientation vertical and now if i go to design now you can see these buttons now if i go to code and uh you can see here we have this layout weight so this layout weight is one and one for this button as well and one for this button as well so it is dividing the whole as you can see here that the width and height is wrap content and then it is this button also vertically taking all the uh width or all the height of this parent layout it is because we have given it a layout weight one for each button so it divides the the screen as we have three button buttons so i divide the screen into three and then it gave to every button a weight of one now if i remove this weight from here and now if i go to design now you can see this button shrinked to its content now if i go to code again and remove this as well and i remove this as well and now if i go to this design you know you will see that these buttons have shrinked itself to its content so i'll go to code and i'll make this uh each of button with match parent as well as this one match parent [Applause] and the first one as well match parent right now if i go to design you will see that each of the pattern has taken the full width of this screen now we will add in another linear layout inside this and in that we will use uh our arrange values in a horizontal manner so i'll make this uh wet width as much parent and i'll make this rape content and i'll use the closing and now inside this i'll use some buttons so i'll use button and now i'll make this uh um wrap content and this one as well the content and i will add a text to this button text and i'll use button and now if i go to design i'll close this tag and now if i go to design now you can see a button here this is is our linear layout which is which we will make horizontal now if i go and add another button here or simply i will copy this button and add it into this linear layout control see this and now all control v this now if i go to design now you can see it is horizontally and added into this linear layout now if i go to code i haven't mentioned here the orientation as horizontal so leon linear layout by default is horizontal now if it does not work you can explicitly use orientation so if i use android orientation and if i use here horizontal now if i go to design now you can see it is a horizontal and now if i make this vertical again so this button will buttons will arrange itself vertically now you can see that it has arranged itself vertically so i'll make this horizontal now i'll add in another button into this so i'll copy this ctrl c this and make some space and ctrl v this now if i go to design now you can see another button is added here and i will copy it one time other control v and now if i go to design now you can see we have buttons uh here now you can also apply margins to this so if i use margins margin 20 dp so now it will take this linear layout will take 20 dp from each side now as it cannot hold all the buttons so that is why it shrink this button this one and it's with increased so i'll make go to code and make this uh 10 db so if i make this 10 db and go to design now you can see all the buttons are uh have um place itself equally now if i run this on emulator so now you can see that it is running on the emulator and this end button has created get a bit more height more than the other buttons because there is not any space or more on this emulator so that is why it strengthens button and as we have wrapped content in this so that is why it uh it's with increase here so i think that's alpha today i hope you liked the video if you like the video please like subscribe and comment thank you
Info
Channel: Programming Guru
Views: 17
Rating: undefined out of 5
Keywords: Programming Guru, Guru Programming, programming, gurru, programminggurru, Koltin tutorial for beginners, Linear layout in android kotlin, linearlayout kotlin android, kotlin tutorial for beginners
Id: en536lHnYsY
Channel Id: undefined
Length: 7min 48sec (468 seconds)
Published: Sun Nov 28 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.