User Interface – Views

Creating and adding a new View to a Layout
XML example – Adding to a view in a layout xml file

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android=""
android:id="@+id/mainLayout" >
    android:text="My text view"

Code example – Creating and adding a new view to a Layout (implemented in an Activity class).

TextView textView = new TextView(this);
textView.setText("My Text View");
        textView ,
        new LayoutParams(LayoutParams.MATCH_PARENT,


android view