Skip to content

Instantly share code, notes, and snippets.

Created May 19, 2015 21:51
Show Gist options
  • Select an option

  • Save anonymous/cd7fda2fa5c4062acb92 to your computer and use it in GitHub Desktop.

Select an option

Save anonymous/cd7fda2fa5c4062acb92 to your computer and use it in GitHub Desktop.
<LinearLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:text="Guest List"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="Kunal"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout>
@lemiakinew
Copy link

What the difference between linearLayout and textView

@foziayube0-cyber
Copy link

TextView

· What it is: A widget for displaying text.
· Purpose: Shows text on the screen (like labels, messages, titles).
· Analogy: A single picture frame that holds a photo (text).
· Example usage:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!" />

LinearLayout

· What it is: A layout container for organizing other views.
· Purpose: Arranges child views in a single row (horizontal) or column (vertical).
· Analogy: A shelf that holds multiple picture frames (TextViews, Buttons, etc.) in a line.
· Example usage:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    
    <TextView android:text="First Item"/>
    <TextView android:text="Second Item"/>
    <Button android:text="Click Me"/>
    
</LinearLayout>

Key Differences

Aspect TextView LinearLayout
Type View (widget) ViewGroup (container)
Purpose Display text Arrange other views
Children Cannot have child views Can contain multiple child views
Common Use Labels, messages, titles Organizing UI elements linearly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment