Views in Android in Hindi
RGPV University / DIPLOMA_CSE / MOBILE COMPUTING
Views in Android
Views in Android
What are Views in Android?
Android में "View" एक UI element होता है, जिसे स्क्रीन पर कुछ दिखाने के लिए उपयोग किया जाता है। Views का उपयोग किसी भी graphical component को प्रदर्शित करने के लिए किया जाता है जैसे कि बटन, टेक्स्ट, इमेज आदि। ये Android ऐप्लिकेशन की बेसिक यूनिट्स होती हैं। Android का UI अलग-अलग Views के माध्यम से बनता है, और ये Views यूजर के साथ इंटरएक्ट करते हैं।
Types of Views (UI Widgets) in Android in Hindi
Android में Views को कई प्रकार से categorize किया जा सकता है। नीचे कुछ प्रमुख प्रकार के Views दिए गए हैं:
- TextView: यह एक View है जो स्क्रीन पर टेक्स्ट को दिखाने के लिए इस्तेमाल किया जाता है। इसे UI में static text को दिखाने के लिए उपयोग किया जाता है।
- Button: यह एक क्लिक करने योग्य View है। यह यूजर से इंटरएक्शन लेने के लिए उपयोग किया जाता है, जैसे कि किसी एक्शन को ट्रिगर करना।
- ImageView: यह View इमेजेस को दिखाने के लिए इस्तेमाल किया जाता है। यह यूजर इंटरफेस में इमेजेज को दिखाने में मदद करता है।
- EditText: यह एक इंटरएक्टिव View है, जो यूजर से टेक्स्ट इनपुट प्राप्त करने के लिए इस्तेमाल किया जाता है।
- CheckBox: यह एक View है जो यूजर को एक या अधिक विकल्पों को चुनने की अनुमति देता है। यह एक "चेक" करने योग्य बॉक्स प्रदान करता है।
- RadioButton: यह View केवल एक विकल्प को चुनने की अनुमति देता है। यह समूह में कार्य करता है, जहाँ एक समय में केवल एक विकल्प चुना जा सकता है।
- ImageButton: यह एक विशेष प्रकार का बटन होता है, जो एक इमेज को बटन के रूप में प्रदर्शित करता है।
- Spinner: यह एक ड्रॉप-डाउन सूची होती है जिसमें यूजर से एक विकल्प चुनने के लिए विकल्प होते हैं।
Layouts vs Views in Android in Hindi
Views और Layouts के बीच में अंतर समझना जरूरी है:
- View: जैसा कि पहले बताया गया, View किसी एक single UI component को कहा जाता है, जैसे TextView, Button, या EditText आदि। यह किसी एक छोटा UI element होता है, जो खुद ही user interaction का हिस्सा हो सकता है।
- Layout: Layout एक container होता है जो multiple Views को एक साथ रखता है। Layouts Views के संगठन और arrangement को नियंत्रित करते हैं। विभिन्न प्रकार के Layouts होते हैं, जैसे LinearLayout, RelativeLayout, ConstraintLayout, आदि।
Types of Layouts in Android in Hindi
Android में Views को बेहतर तरीके से organize करने के लिए विभिन्न प्रकार के Layouts होते हैं:
- LinearLayout: यह Layout child Views को एक लाइन में (या तो Horizontal या Vertical) व्यवस्थित करता है। यह बहुत आसान और सबसे सामान्य Layout होता है।
- RelativeLayout: यह Layout child Views को एक दूसरे के सापेक्ष व्यवस्थित करता है। उदाहरण के लिए, एक View को दूसरे View के ऊपर या नीचे रखा जा सकता है।
- FrameLayout: यह Layout सभी child Views को एक दूसरे के ऊपर stack करता है। इसका उपयोग तब किया जाता है जब आप चाहें कि Views एक दूसरे के ऊपर दिखाई दें।
- ConstraintLayout: यह Layout Views को flexible और responsive तरीके से arrange करने के लिए प्रयोग किया जाता है। इसके माध्यम से हम Views को विभिन्न constraints के आधार पर arrange कर सकते हैं।
How Layouts and Views Work Together in Android in Hindi
Views और Layouts एक साथ काम करते हैं ताकि UI elements को स्क्रीन पर सही तरीके से प्रस्तुत किया जा सके। Layouts Views को organize करते हैं और Views यूजर से इनपुट या इंटरएक्शन लेते हैं। उदाहरण के लिए, यदि आप एक बटन (Button) और टेक्स्ट (TextView) को एक साथ स्क्रीन पर दिखाना चाहते हैं, तो आप एक Layout का उपयोग करेंगे (जैसे LinearLayout) और उसमें इन दोनों Views को arrange करेंगे।
Example of Layout with Views in Android
नीचे एक सरल उदाहरण है, जिसमें LinearLayout का उपयोग किया गया है और उसमें TextView और Button Views को रखा गया है:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello, Android!" />
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me!" />
</LinearLayout>
Conclusion in Hindi
इस प्रकार, Android में Views और Layouts का उपयोग UI elements को व्यवस्थित करने और उपयोगकर्ता से इंटरएक्ट करने के लिए किया जाता है। सही प्रकार के Views और Layouts का चुनाव UI के usability और responsiveness को बेहतर बना सकता है।
FAQs
In Android, a View is a UI component that displays content on the screen. It could be a TextView, Button, or any other UI widget. Views are the building blocks for creating the user interface in an Android application. (Android में View एक UI घटक है जो स्क्रीन पर सामग्री दिखाता है। यह TextView, Button, या कोई अन्य UI विजेट हो सकता है। Views Android ऐप्लिकेशन में यूजर इंटरफेस बनाने के लिए बिल्डिंग ब्लॉक्स होते हैं।)
Views are individual UI elements like Buttons, TextViews, or EditTexts that handle user interaction. Layouts, on the other hand, are containers that organize these Views. For example, a LinearLayout arranges Views in a single line, either horizontally or vertically. (Views वे व्यक्तिगत UI तत्व होते हैं जैसे Buttons, TextViews, या EditTexts जो यूजर इंटरएक्शन को हैंडल करते हैं। Layouts, दूसरी ओर, ऐसे कंटेनर होते हैं जो इन Views को व्यवस्थित करते हैं। उदाहरण के लिए, LinearLayout Views को एक लाइन में, या तो क्षैतिज या लंबवत, व्यवस्थित करता है।)
Some common types of Views in Android are TextView, Button, ImageView, EditText, CheckBox, RadioButton, and Spinner. Each of these Views serves a different purpose in the UI of an Android application. (Android में कुछ सामान्य प्रकार के Views हैं: TextView, Button, ImageView, EditText, CheckBox, RadioButton, और Spinner। इन सभी Views का उपयोग Android ऐप्लिकेशन के UI में अलग-अलग उद्देश्यों के लिए किया जाता है।)
Layouts organize Views by arranging them in a particular order or structure. For example, a LinearLayout arranges Views in a horizontal or vertical line, while a RelativeLayout arranges Views based on their relationships to each other. (Layouts Views को एक विशेष क्रम या संरचना में व्यवस्थित करते हैं। उदाहरण के लिए, LinearLayout Views को क्षैतिज या लंबवत क्रम में व्यवस्थित करता है, जबकि RelativeLayout Views को उनके आपसी संबंधों के आधार पर व्यवस्थित करता है।)
A Button in Android is used to perform an action when clicked by the user. For example, it can submit a form, navigate to another screen, or trigger a specific event in the app. (Android में Button का उपयोग तब किया जाता है जब यूजर इसे क्लिक करता है, और यह कोई कार्य करता है। उदाहरण के लिए, यह एक फॉर्म को सबमिट कर सकता है, किसी अन्य स्क्रीन पर जा सकता है, या ऐप में किसी विशेष इवेंट को ट्रिगर कर सकता है।)
A Spinner is used to display a drop-down list of options from which the user can select a value. It is often used when there is a need to provide multiple choices in a compact form. (Spinner का उपयोग एक ड्रॉप-डाउन सूची दिखाने के लिए किया जाता है जिसमें यूजर एक विकल्प चुन सकता है। इसका उपयोग तब किया जाता है जब एक संकुचित रूप में कई विकल्पों को प्रदान करने की आवश्यकता होती है।)