A TextView in Android displays to the user and allows them to programmatically edit it. The TextView class is derived from the View class. In terms of the user experience, this has a significant impact on how information is displayed. TextView will behave like a label control and you will not be able to edit it.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:p="Android Aura"/>
TextView tv = findViewById(R.id.tv);
tv.setText("Android Aura");
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".MainActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:p="Welcome to Techstackguru!"
android:textColor="#03A9F4"
android:textSize="22dp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
//XML
android:textColor="#1C83EA"
android:textColor="@color/colorAccent"
//JAVA
tv.setTextColor(Color.BLUE);
tv.setTextColor(Color.parseColor("#00abd7"));
//styles.xml
//<item name="colorAccent">@color/colorAccent</item>
tv.setTextColor(getResources().getColor(R.color.colorAccent));
//XML
android:background="#F7DC6F"
//JAVA
tv.setBackgroundColor(Color.parseColor("#F7DC6F"));
//XML
android:textAllCaps="true"
//JAVA
tv.setAllCaps(true);
//XML
android:fontFamily="sans-serif"
//XML
android:textStyle="bold"
android:textStyle="italic"
android:textStyle="normal"
//JAVA
tv.setTypeface(Typeface.DEFAULT_BOLD);