تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
يتيح لك نظام التشغيل Android بصفتك مطوّرًا الاستفادة من إمكانات الويب في تطبيقك الأصلي، ما يتيح لك الاستفادة من مرونة عرض أنواع معيّنة من المحتوى وكفاءته.
تضمين المحتوى باستخدام WebView
تتيح واجهة برمجة التطبيقات WebView للمطوّرين إمكانية الوصول إلى إمكانات متصفّح صغير لعرض محتوى الويب داخل تطبيقك. يتيح لك ذلك تقديم تجارب مستندة إلى الويب كجزء أساسي أو داعم في تطبيقك، كما هو موضّح في الشكل 1.
الشكل 1. محتوى الويب المضمّن في التطبيق باستخدام
مكوّنات WebView كمحتوى أساسي (على اليمين) ومحتوى داعم (على اليسار)
ما هي وظيفة WebView؟
إليك ما يمكنك فعله باستخدام WebView في تطبيقك:
تضمين الويب: يتم دمج WebView في واجهة مستخدم التطبيق كأحد المكوّنات، مثل زر أو حقل نص.
تحميل المحتوى: يمكن لـ WebView تحميل محتوى الويب من مصادر مختلفة:
عناوين URL عن بُعد: يمكنها استرجاع صفحات الويب وعرضها من الإنترنت، تمامًا مثل أي متصفّح عادي.
الملفات المحلية: يمكنه تحميل ملفات HTML وCSS وJavaScript المخزَّنة ضمن موارد التطبيق.
المحتوى الذي يتم إنشاؤه ديناميكيًا: يمكن للتطبيق إنشاء محتوى HTML أثناء التنقل
وتقديمه إلى WebView.
العرض: تستخدم WebView محرك المتصفح الخاص بها لتحليل وعرض HTML وCSS وJavaScript، ما يؤدي إلى عرض صفحة الويب الناتجة ضمن المساحة المخصّصة لها في واجهة مستخدم التطبيق.
تنفيذ JavaScript: يمكن لمكوّن WebView تنفيذ رمز JavaScript ضمن سياق صفحة الويب التي تم تحميلها. يتيح ذلك تفاعلات ديناميكية وتعديلات داخل WebView.
التفاعل مع التطبيق الأصلي: هنا تزداد فعالية WebView. ويتيح ذلك التواصل في اتجاهين بين صفحة الويب والتطبيق.
JavaScript إلى الرمز البرمجي الأصلي: يمكن لرمز JavaScript الذي يتم تشغيله في WebView استدعاء واجهات برمجة التطبيقات المضيفة للتطبيق، ما يتيح الوصول إلى ميزات الجهاز، مثل الكاميرا أو نظام تحديد المواقع العالمي (GPS) أو أجهزة الاستشعار.
التوافق مع JavaScript: يمكن للتطبيق أيضًا إدراج رمز JavaScript في WebView، أو تعديل محتوى صفحة الويب، أو الاستجابة للأحداث التي يتم تشغيلها بواسطة صفحة الويب.
ما الفرق بين WebView ومتصفّح عادي مثل Chrome؟
WebView هو مكوّن قابل للتخصيص بدرجة كبيرة يوفّر الوظيفة الأساسية لنافذة على الويب. على عكس المتصفّح الذي يوفّر معظم شريط التنقّل واحتياجات المستخدمين الأخرى للتنقّل على الويب بشكل أوسع، فإنّ التجربة الإجمالية لـ WebView تتحدّد من خلال تصميم تطبيقك والغرض منه.
لفهم الفرق بين WebView والمتصفّحات العادية بشكل أفضل، اطّلِع على التوضيحات التالية:
واجهة المستخدم: يتم استخدام WebView لعرض محتوى الويب، وليس لديها عنوان أو واجهة مستخدم خاصة بها مثل معظم المتصفحات الشائعة الأخرى (زر الصفحة الرئيسية وشريط عناوين URL وأزرار التنقّل والإعدادات وما إلى ذلك).
الميزات: أضافت العديد من المتصفحات ميزات إضافية لتحسين تجربة التصفّح، مثل الإشارات المرجعية أو الأذونات أو السجلّ.
التحديثات: بما أنّ Android WebView هي خدمة نظام على Android، يتم إرسال التحديثات ودمجها في التطبيقات تلقائيًا على أساس شهري. تعتمد المتصفّحات على تحديثات التطبيقات المقابلة، ثم على المستخدمين النهائيين لتطبيق التحديث على أجهزتهم.
من أين نبدأ؟
للحصول على معلومات حول كيفية استخدام WebView في تطبيقك، يُرجى الاطّلاع على المقالة
إنشاء تطبيقات ويب في WebView.
مراجع إضافية
لتطوير صفحات ويب للأجهزة التي تعمل بنظام التشغيل Android باستخدام عناصر WebView أو علامات التبويب المخصّصة، راجِع المستندات التالية:
يخضع كل من المحتوى وعيّنات التعليمات البرمجية في هذه الصفحة للتراخيص الموضحّة في ترخيص استخدام المحتوى. إنّ Java وOpenJDK هما علامتان تجاريتان مسجَّلتان لشركة Oracle و/أو الشركات التابعة لها.
تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)
[[["يسهُل فهم المحتوى.","easyToUnderstand","thumb-up"],["ساعَدني المحتوى في حلّ مشكلتي.","solvedMyProblem","thumb-up"],["غير ذلك","otherUp","thumb-up"]],[["لا يحتوي على المعلومات التي أحتاج إليها.","missingTheInformationINeed","thumb-down"],["الخطوات معقدة للغاية / كثيرة جدًا.","tooComplicatedTooManySteps","thumb-down"],["المحتوى قديم.","outOfDate","thumb-down"],["ثمة مشكلة في الترجمة.","translationIssue","thumb-down"],["مشكلة في العيّنات / التعليمات البرمجية","samplesCodeIssue","thumb-down"],["غير ذلك","otherDown","thumb-down"]],["تاريخ التعديل الأخير: 2025-08-27 (حسب التوقيت العالمي المتفَّق عليه)"],[],[],null,["# Embedding web content into your app as primary or supporting content\n\nAndroid allows you as a developer to build on the power of the web within your\nnative application, so you can benefit from the flexibility and efficiency of\ndisplaying certain types of content.\n\nEmbedding content using WebView\n-------------------------------\n\nThe [WebView](/reference/android/webkit/WebView) API gives developers\naccess to the capabilities of a mini-browser for displaying web content within\nyour application. This lets you provide web-powered experiences as a core\nor supporting part within your application, as seen in **Figure 1**.\n**Figure 1.** Web content embedded within the app with WebViews as primary (left) and supporting content (right).\n\nWhat can WebView do?\n--------------------\n\nThis is what you can do with WebView in your application:\n\n**Embed web**: A WebView is integrated into an app's user interface as a\ncomponent, much like a button or text field.\n\n**Load content**: WebView can load web content from various sources:\n\n- Remote URLs: It can fetch and display web pages from the internet, just like a regular browser.\n- Local files: It can load HTML, CSS, and JavaScript files stored within the app's resources.\n- Dynamically generated content: The app can generate HTML content on-the-fly and feed it to the WebView.\n\n**Render**: WebView uses its browser engine to parse and render the HTML,\nCSS, and JavaScript, displaying the resulting web page within its designated\narea in the app's UI.\n\n**Execute JavaScript**: WebView can execute JavaScript code within the\ncontext of the loaded web page. This allows for dynamic interactions and\nupdates within WebView.\n\n**Native app interaction**: This is where WebView gets more powerful. It allows\nfor bidirectional communication between the web page and the app.\n\n- JavaScript to native: JavaScript code running in WebView can call host APIs of the app, enabling access to device features like camera, GPS, or sensors.\n- Native to JavaScript: The app can also inject JavaScript code into WebView, manipulate the web page's content, or respond to events triggered by the web page.\n\nHow is WebView different from a typical browser like Chrome?\n------------------------------------------------------------\n\nWebView is a highly custom component which provides the core functionality of a\nwindow into the web. Unlike a browser, which provides much of the navigation bar\nand other user needs to navigate the web more broadly, the overall experience of\nWebView is shaped by your app's design and purpose.\n\nTo better understand how WebView differs from standard browsers, see the\nfollowing explanations:\n\n**UI**: WebView is used for displaying web content, and does not have its own\nheader or UI like most other common browsers (home button, URL bar, navigation,\nsettings, etc.)\n\n**Features**: Many browsers have built additional features to augment the\nbrowsing experience such as bookmarks, permissions, or history.\n\n**Updates**: Because Android WebView is a system service on Android, updates are\npushed and integrated into the apps automatically on a monthly basis. Browsers\nrely on their corresponding app updates and then for end users to apply the\nupdate on their devices.\n\nWhere to start?\n---------------\n\nFor information on how to use WebView in your app, see the article\n[Build web apps in WebView](/guide/webapps/webview).\n\n### Additional resources\n\nTo develop web pages for Android-powered devices using WebView objects or Custom\nTabs, see the following documents:\n\n- [Build web apps in WebView](/guide/webapps/webview)\n- [Manage WebView objects](/guide/webapps/managing-webview)\n- [Support different screens in web apps](/guide/webapps/targeting)\n- [Debug web apps](/guide/webapps/debugging)\n- [Best practices for web apps](/guide/webapps/best-practices)\n- [Opt-in to WebView Beta](https://play.google.com/apps/testing/com.google.android.webview)\n- [In-app browsing using Embedded Web](/develop/ui/views/layout/webapps/in-app-browsing-embedded-web)\n- [Overview of Android Custom Tabs](/develop/ui/views/layout/webapps/overview-of-android-custom-tabs)"]]