How to Create Text View In Android Studio.
Sr.No. | Attribute & Description |
---|---|
1 | android: id This is the ID that uniquely identifies the control. |
2 | android: capitalize If set specifies that this TextView has a textual input method and should automatically capitalize on what the user types.
|
3 | android: cursorvisible Makes the cursor visible (the default) or invisible. The default is false. |
4 | android: editable If set to true, specifies that this TextView has an input method. |
5 | android:fontFamily Font family (named by string) for the text. |
6 | android:gravity Specifies how to align the text by the view's x- and/or y-axis when the text is smaller than the view. |
7 | android:hint Hint text to display when the text is empty. |
8 | android:inputType The type of data being placed in a text field. Phone, Date, Time, Number, Password etc. |
9 | android:maxHeight Makes the TextView be at most this many pixels tall. |
10 | android:maxWidth Makes the TextView be at most this many pixels wide. |
11 | android:minHeight Makes the TextView be at least this many pixels tall. |
12 | android:minWidth Makes the TextView be at least this many pixels wide. |
13 | android:password Whether the characters of the field are displayed as password dots instead of themselves. Possible value either "true" or "false". |
14 | android:phoneNumber If set, specifies that this TextView has a phone number input method. Possible value either "true" or "false". |
15 | android:text Text to display. |
16 | android:textAllCaps Present the text in ALL CAPS. Possible value either "true" or "false". |
17 | android:textColor Text color. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
18 | android:textColorHighlight Color of the text selection highlight. |
19 | android:textColorHint Color of the hint text. May be a color value, in the form of "#rgb", "#argb", "#rrggbb", or "#aarrggbb". |
20 | android:textIsSelectable Indicates that the content of a non-editable text can be selected. Possible value either "true" or "false". |
21 | android:textSize Size of the text. Recommended dimension type for text is "sp" for scaled-pixels (example: 15sp). |
22 | android:textStyle Style (bold, italic, bolditalic) for the text. You can use or more of the following values separated by '|'.
|
23 | android:typeface Typeface (normal, sans, serif, monospace) for the text. You can use or more of the following values separated by '|'.
|
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".MainActivity">
<TextView
android:background="#F3F3F3"
android:gravity="center"
android:id="@+id/textview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="My First Text View "
android:textColor="#FF0101"
android:textSize="30dp"
android:textStyle="bold"
android:layout_margin="10dp"
android:padding="20dp"
android:textAllCaps="false"
/>
</LinearLayout>
MainActivity.Java
this is a Codeing file in Android Studio
package com.example.MyFirstTextView;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView=findViewById(R.id.textview);
textView.setText("My First Text View");
}
}output is-
Comments
Post a Comment