Android ContentViews


Android ContentViews Tutorial.

Types of Android ContentViews

Let's look at some examples.

AppCompatTextView is basically a TextView which provides support to older version of the android platform with compatible features of a TextView.

Whenever you use a TextView, android may automatically use the AppCompatTextView.

This is if your project has the necessary support library dependencies.

AppCompatTextView resides in the android.support.v7.widget package.

package android.support.v7.widget;

This class derives from TextView:

public class AppCompatTextView extends TextView{}

Given that it derives from android.widget.TextView, this class inherits TextView's XML attributes. Some of these attributes are inherited by TextView itself from the base View class.

Android ImageView Tutorial.

MarqueeView is a custom slider view that can slide vertically and horizontally.

Android TextView is a User interface widget that displays basic texts.

In almost every Graphical User Interface toolkit out there, a component or control for displaying text is there. Be it the Label in Windows Forms or the JLabel in Swing.

This is because we mostly communicate via texts and these texts have to be rendered. Well the textview renders them in Android.

TextViews and labels are normally considered basic and are easy to work with.

In android textviews are actually editable though by default this is disabled. Instead it's subclass the EditText on the other hand allows for editing.

TextView as a class resides in the android.widget package.

package android.widget;

TextView derives from android.view.View class and implements import android.view.ViewTreeObserver.OnPreDrawListener.

public class TextView extends View implements OnPreDrawListener {}

android.widget.TextView is a class used to render texts.

java.lang.StringBuilder on the other hand allows for creation of modifiable string of characters. StringBuilder is the replacemnet for StringBuffer class for non-concurrent use.

In this example we'll see how to:

  • Create a StringBuilder with multiple items.
  • Render the StringBuilder items in a TextView line by line.

For this example we don't need any XML layout. Instead we create and set an android.view.View object as our contentView for our activity.

Let's go.

Cheers.

How do You Feel after reading this?

According to scientists, we humans have 8 primary innate emotions: joy, acceptance, fear, surprise, sadness, disgust, anger, and anticipation. Feel free to tell us how you feel about this article using these emotes or via the comment section. This feedback helps us gauge our progress.

Help me Grow.

I set myself some growth ambitions I desire to achieve by this year's end regarding this website and my youtube channel. Am halfway. Help me reach them by:




Recommendations


What do You Think

Dear readers drop us your comments below. We are building a community of students and learners. Start by dropping us your suggestions below. What tutorials do you want us to do for example? Where can we improve? What are some awesome resources out there? Do you have any code you want to share with us?
By the way that example or snippet you have lying in your computer can really help beginner programmers. We can share it here with other students.

Previous Post Next Post