Hi guys in this tutorial I will talk about textview and edittext components.
Texts that are to be displayed on the screen are displayed to the user with textview.
For example, consider a login page,there are two different text for enter your username and password on the screen. Of course, in addition to these texts, you can enter your username and password in the fields. Here we show these texts with textview and the field to enter data with edittext.
As we can seen from the above example, edittext provides data flow from users to the application.
<Linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" >
<TextView android:id="@+id/textView1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="98dp" android:text="kullanıcı Adinizi giriniz:" /> <EditText android:id="@+id/editText1" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="63dp" android:hint="kullanıcı adınızı buraya giriniz..." </EditText> </LinearLayout>
If we examine the above example;
First of all, we define our layout. For this example, I used the linearlayout. We set the height and width of the layout to match_parent and orientation to horizontal. With Horizontal, we ensure that the components written in the layout are listed one by one.
With Textview, we show the user the text you enter your username. We define the id variable to use textview in Java coding.We set the height to wrap_content and the width to match_parent. Here we see the margin top feature for the first time, this feature set how much space will be set from the top of the textview. For this example , we set this value to 98 dp.
After the textview component, we define the edittext component. we are setting id, height and width values for edittext.
We leave 63 dp link space between textview and edittext. With hint feature, the user is given tips. One of the important points here is to define the id values of all components.
The second one is to close each tag. For example, we have to close the tag that we opened with <textview… ..> in the texttextview>.
799 views last month, 2 views today