Hi..
The topic I am going to explain here is TextView. Text view is a small view that is used to show a simple text in an Android Application. TextView can be modified according to the need of the application. For example: If someone want to change the color, size and font etc. of the text.
Here are some properties of TextView.
Apply External Font in Text:
Define TextView in XML
Use TextView in Java class file.
TextView text=(TextView)findViewById(R.id.textView1);
text.setText("This is the sample text...");
Above is the way to use Textview in android.
# Create the object of TextView Class:
TextView text;
# Get id of Textview defined in the xml file.
text=(TextView)findViewById(R.id.textView1);
# Set the text that you want to show in TextView:
text.setText("This is the sample text...");
This way you can use the TextView in your.
This is all about TextView
Thanks!!!!!!!
The topic I am going to explain here is TextView. Text view is a small view that is used to show a simple text in an Android Application. TextView can be modified according to the need of the application. For example: If someone want to change the color, size and font etc. of the text.
Here are some properties of TextView.
Properties
|
Code
|
Set Width of TextView
· Wrap_content : width equals to the text in the textview.
· Match_parent: Width equals to the width of parent layout of textview.
|
android:layout_width="match_parent"
or
android:layout_width="wrap_content"
|
Set height of TextView
|
android:layout_height="match_parent"
or
android:layout_height="wrap_content"
|
Set Text Color
· #ffffff : color code for white color
· @color/white: if defined in color.xml
· @android:color: use OS defined color.
|
android:textColor="#ffffff"
or
android:textColor="@color/white"
or
android:textColor="@android:color/WHITE"
|
Set TextSize:
| |
Apply External Font in Text:
Typeface type = Typeface.createFromAsset(getAssets(),"fonts/Helvetica.ttf");
TextView tv = (TextView) findViewById(R.id.text);
tv.setTypeface(type);
Define TextView in XML
Use TextView in Java class file.
TextView text=(TextView)findViewById(R.id.textView1);
text.setText("This is the sample text...");
Above is the way to use Textview in android.
# Create the object of TextView Class:
TextView text;
# Get id of Textview defined in the xml file.
text=(TextView)findViewById(R.id.textView1);
# Set the text that you want to show in TextView:
text.setText("This is the sample text...");
This way you can use the TextView in your.
This is all about TextView
Thanks!!!!!!!
No comments:
Post a Comment