Android UIs Views (UI widgets ਜਿਵੇਂ buttons, text) ਤੋਂ ਬਣਾਏ ਜਾਂਦੇ ਹਨ ਜੋ ViewGroups/layouts (containers ਜਿਵੇਂ LinearLayout, ConstraintLayout) ਦੁਆਰਾ ਵਿਵਸਥਿਤ ਹੁੰਦੇ ਹਨ। ਰਵਾਇਤੀ ਤੌਰ 'ਤੇ XML layouts ਵਿੱਚ ਪਰਿਭਾਸ਼ਿਤ, ਆਧੁਨਿਕ Android ਵੱਡੇ ਪੱਧਰ 'ਤੇ Jetpack Compose (declarative) ਦੀ ਵਰਤੋਂ ਕਰ ਰਿਹਾ ਹੈ। View system ਨੂੰ ਸਮਝਣਾ UIs ਬਣਾਉਣ ਲਈ ਬੁਨਿਆਦੀ ਹੈ।
Views ਅਤੇ ViewGroups
VIEW → a single UI element (TextView, Button, ImageView, EditText, etc.)
VIEWGROUP → a container that holds/arranges child views (LinearLayout, ConstraintLayout,
FrameLayout, RecyclerView, etc.) — layouts ARE ViewGroups
→ UIs are a TREE of views inside view groups (composition).
Common layouts (ViewGroups)
LinearLayout → arrange children in a row OR column
ConstraintLayout → flexible, flat layouts via constraints between views (modern, efficient,
the recommended layout for complex UIs)
FrameLayout → stack/overlay children
RecyclerView → efficient scrolling lists (recycles views for performance — key for lists)
XML layouts (ਰਵਾਇਤੀ)
<!-- define the UI declaratively in an XML layout file -->
<LinearLayout android:orientation="vertical" ...>
<TextView android:text="Hello" .../>
<Button android:id="@+id/myButton" android:text="Click" .../>
</LinearLayout>
// access views in code (via findViewById or View Binding)
binding.myButton.setOnClickListener { /* handle click */ }
ਆਧੁਨਿਕ: Jetpack Compose
JETPACK COMPOSE → modern DECLARATIVE UI toolkit (Kotlin code, no XML):
→ describe UI as composable functions; reactive (UI updates with state)
→ Google's recommended modern approach (similar idea to Flutter/React)
→ New apps increasingly use Compose; XML layouts still common in existing apps.
ਇਹ ਕਿਉਂ ਜ਼ਰੂਰੀ ਹੈ
Layouts ਅਤੇ views ਕਿਵੇਂ ਕੰਮ ਕਰਦੇ ਹਨ ਇਹ ਸਮਝਣਾ Android development ਲਈ ਬੁਨਿਆਦੀ ਹੈ ਕਿਉਂਕਿ UIs ਬਣਾਉਣਾ ਐਪਸ ਦਾ ਮੂਲ ਹੈ, ਇਸ ਲਈ ਇਹ ਮੁਸ਼ਤ-ਜਾਨਣਯੋਗ ਗਿਆਨ ਹੈ।
ਰਵਾਇਤੀ Android view system Views (ਵਿਅਕਤੀਗਤ UI elements ਜਿਵੇਂ buttons ਅਤੇ text) ਤੋਂ ਬਣਿਆ ਹੋਇਆ ਹੈ ਜੋ ViewGroups/layouts (containers ਜਿਵੇਂ LinearLayout ਅਤੇ ConstraintLayout) ਦੁਆਰਾ ਇੱਕ ਰੁੱਖ ਵਿੱਚ ਵਿਵਸਥਿਤ ਹੁੰਦੇ ਹਨ — ਇਸ composition model ਨੂੰ ਸਮਝਣਾ ਕਿਸੇ ਵੀ Android UI ਬਣਾਉਣ ਲਈ ਬੁਨਿਆਦੀ ਹੈ।
Common layouts ਨੂੰ ਸਮਝਣਾ — LinearLayout (rows/columns), ConstraintLayout (ਸਿਫਾਰਸ਼ ਕੀਤਾ ਫਲੈਕਸੀਬਲ, ਕੁਸ਼ਲ layout ਕਮਪਲੈਕਸ UIs ਲਈ), FrameLayout (overlays), ਅਤੇ ਖਾਸ ਤੌਰ 'ਤੇ RecyclerView (ਕੁਸ਼ਲ scrolling lists ਜੋ performance ਲਈ views ਨੂੰ ਰੀਸਾਈਕਲ ਕਰਦੇ ਹਨ — ਡਾਟਾ ਦੀ ਕਿਸੇ ਵੀ ਲਿਸਟ ਲਈ ਮਹੱਤਵਪੂਰਨ) — ਲਾਜ਼ਮੀ ਵਿਹਾਰਕ ਗਿਆਨ ਹੈ।
XML layouts ਨੂੰ ਸਮਝਣਾ (UIs ਨੂੰ ਪਰਿਭਾਸ਼ਿਤ ਕਰਨ ਦਾ ਰਵਾਇਤੀ declarative ਤਰੀਕਾ, code ਵਿੱਚ findViewById ਜਾਂ View Binding ਦੁਆਰਾ ਐਕਸੈਸ ਕੀਤਾ) ਜ਼ਰੂਰੀ ਹੈ ਕਿਉਂਕਿ ਬਹੁਤ ਸਾਰਾ ਮੌਜੂਦਾ Android code ਉਨ੍ਹਾਂ ਦੀ ਵਰਤੋਂ ਕਰਦਾ ਹੈ।
ਮਹੱਤਵਪੂਰਨ ਤੌਰ 'ਤੇ, ਇਹ ਸਮਝਣਾ ਕਿ ਆਧੁਨਿਕ Android ਵੱਡੇ ਪੱਧਰ 'ਤੇ Jetpack Compose (Google ਦਾ ਸਿਫਾਰਸ਼ ਕੀਤਾ declarative UI toolkit, Kotlin ਵਿੱਚ XML ਤੋਂ ਬਿਨਾ ਲਿਖਿਆ, UI ਨੂੰ composable functions ਦੇ ਤੌਰ 'ਤੇ ਵਰਣਿਤ ਜੋ state ਪ੍ਰਤਿ ਪ੍ਰਤੀਕ੍ਰਿਆ ਕਰਦੇ ਹਨ — ਸੰਕਲਪਿਤ ਤੌਰ 'ਤੇ Flutter ਅਤੇ React ਵਰਗਾ) ਦੀ ਵਰਤੋਂ ਕਰ ਰਿਹਾ ਹੈ, Android UI development ਦੀ ਮੌਜੂਦਾ ਦਿਸ਼ਾ ਨੂੰ ਪ੍ਰਤੀਬਿੰਬਿਤ ਕਰਦਾ ਹੈ, ਕਿਉਂਕਿ ਨਵੀਆਂ ਐਪਸ ਵੱਡੇ ਪੱਧਰ 'ਤੇ Compose ਨੂੰ ਅਪਣਾ ਰਹੀਆਂ ਹਨ ਜਦਕਿ XML ਮੌਜੂਦਾ ਐਪਸ ਵਿੱਚ ਆਮ ਹੈ।
Rvraiti view/XML system ਅਤੇ ਆਧੁਨਿਕ Compose approach ਦੋਵਾਂ ਨੂੰ ਸਮਝਣਾ Android UI development ਦੀ ਸੰਪੂਰਨ ਤਸਵੀਰ ਦਿੰਦਾ ਹੈ।
ਕਿਉਂਕਿ UIs ਬਣਾਉਣਾ Android ਐਪਸ ਲਈ ਮੂਲ ਹੈ ਅਤੇ view system (Views, ViewGroups, layouts, RecyclerView) ਅਤੇ XML layouts ਰਵਾਇਤੀ Android UI ਦੀ ਬੁਨਿਆਦ ਹਨ ਜਦਕਿ Jetpack Compose ਆਧੁਨਿਕ declarative approach ਹੈ, ਅਤੇ ਕਿਉਂਕਿ ਦੋਵਾਂ ਨੂੰ ਸਮਝਣਾ Android UIs ਬਣਾਉਣ ਲਈ ਲਾਜ਼ਮੀ ਹੈ (ਮੌਜੂਦਾ ਅਤੇ ਨਵੀਆਂ), layouts ਅਤੇ views ਕਿਵੇਂ ਕੰਮ ਕਰਦੇ ਹਨ ਇਹ ਸਮਝਣਾ Android ਵਿੱਚ ਜ਼ਰੂਰੀ, ਬੁਨਿਆਦੀ ਗਿਆਨ ਹੈ — ਰਵਾਇਤੀ view system (ਅਜੇ ਵਿਆਪਕ ਤੌਰ 'ਤੇ ਵਰਤਿਆ ਜਾਂਦਾ) ਅਤੇ ਆਧੁਨਿਕ Compose toolkit (ਸਿਫਾਰਸ਼ ਕੀਤੀ ਦਿਸ਼ਾ) ਨੂੰ ਸ਼ਾਮਲ ਕਰਦੇ ਹੋਏ Android interfaces ਬਣਾਉਣ ਲਈ ਮੂਲ — ਕਿਸੇ ਵੀ Android UI development ਲਈ ਲਾਜ਼ਮੀ।
