Fundamentals: Basic Building blocks – Activities, Services, Broadcast Receivers & Content providers,in hindi

Android Activity

अगर आपकी application में GUI Screen है तो activity भी जरूर होगी। एक GUI Screen और activity में one to one relationship होती है। जेसे MVC paradigm में controller view को control करता है उसी प्रकार एक activity आपकी android application में GUI Screen को control करती है।

आप अपनी android application में जितनी GUI Screen चाहते है आपको उतनी ही activity create करनी होगी। हर activity एक GUI Screen को display करती है।

जब भी user GUI Screen के द्वारा कोई events generate करते है तो activity उन events को handle करने के लिए responsible होती है। कई बार activity system generated events को भी handle करती है।

GUI Screen में elements display करने के लिए activity views की मदद लेती है। हर view एक different element को represent करता है।

Android activity create करने के लिए आपको Activity class को extend करना होता है। जिसका  उदाहरण आपको नीचे दिया जा रहा है।

public class yr_cls_nm extends Activity
{
}

Android Service

यदि किसी application को बहुत देर तक execute होना है तो उसे service की तरह implement करना बेहतर होता है। आप जब चाहे एक service launch कर सकते है और काम पूरा होने पर उसे terminate कर सकते है।

Services background में यह run होती है और इनका user interface नहीं होता है। एक android service create करने के लिए आपको Service class को extend करना होता है। इसका उदाहरण नीचे दिया गया है।

public class yur_cls_nm  extends  Service
{
 }

Android Broadcast Receiver 

Intents का notification पाने के लिए एक application को खुद को broadcast receiver की तरह ही register करवाना होता है।

किसी application को register करवाने के लिए आपको AndroidManfest.xml file में receiver element को include करना पड़ता है। और इसके name attribute में अपनी class का नाम pass करना होता है। क्लास से पहले आपको dot operator (.) लगाना होता है। इसका उदाहरण नीचे दिया गया है।

<receiver android:name=".yourclassname">
</receiver>

receiver tags अंदर आप intent-filter tag यूज़ कर सकते है।

<receiver android :name =".yourclassname ">
<intent-filter>
<action android:name ="action_name">
</intent-filter>
</receiver>

Android Content Provider 

यदि एक application अपना data किसी दूसरी application के साथ share करना चाहती है तो ऐसा content provider के साथ किया जा सकता है। किसी application का data उसके content provider में store होता है।  जब भी एक application किसी दूसरी application के data को access करना चाहती है तो वो उस application के content provider को एक्सेस करती है। Content provider में कुछ methods होते है जो किसी application को डेटा access करने की permission देते है।

source link 

android First sample Application in hindi

Create Android Application

The first step is to create a simple Android Application using Android studio. When you click on Android studio icon, it will show screen as shown below

Hello Android Wizard

You can start your application development by calling start a new android studio project. in a new installation frame should ask Application name, package information and location of the project.−

Hello Android Project

After entered application name, it going to be called select the form factors your application runs on, here need to specify Minimum SDK, in our tutorial, I have declared as API23: Android 6.0(Mashmallow) −

Hello Android Project

The next level of installation should contain selecting the activity to mobile, it specifies the default layout for Applications.

Hello Android Project

At the final stage it going to be open development tool to write the application code.

Hello Android Project

Anatomy of Android Application

Before you run your app, you should be aware of a few directories and files in the Android project −

Android Directory Structure
Sr.No.Folder, File & Description
1JavaThis contains the .java source files for your project. By default, it includes an MainActivity.java source file having an activity class that runs when your app is launched using the app icon.
2res/drawable-hdpiThis is a directory for drawable objects that are designed for high-density screens.
3res/layoutThis is a directory for files that define your app’s user interface.
4res/valuesThis is a directory for other various XML files that contain a collection of resources, such as strings and colours definitions.
5AndroidManifest.xmlThis is the manifest file which describes the fundamental characteristics of the app and defines each of its components.
6Build.gradleThis is an auto generated file which contains compileSdkVersion, buildToolsVersion, applicationId, minSdkVersion, targetSdkVersion, versionCode and versionName

Following section will give a brief overview of the important application files.

The Main Activity File

The main activity code is a Java file MainActivity.java. This is the actual application file which ultimately gets converted to a Dalvik executable and runs your application. Following is the default code generated by the application wizard for Hello World! application −

package com.example.helloworld;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class MainActivity extends AppCompatActivity {
   @Override
   protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
   }
}

Here, R.layout.activity_main refers to the activity_main.xml file located in the res/layout folder. The onCreate() method is one of many methods that are figured when an activity is loaded.

The Manifest File

Whatever component you develop as a part of your application, you must declare all its components in a manifest.xml which resides at the root of the application project directory. This file works as an interface between Android OS and your application, so if you do not declare your component in this file, then it will not be considered by the OS. For example, a default manifest file will look like as following file −

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.tutorialspoint7.myapplication">

   <application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme">
      
      <activity android:name=".MainActivity">
         <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
         </intent-filter>
      </activity>
   </application>
</manifest>

Here <application>…</application> tags enclosed the components related to the application. Attribute android:icon will point to the application icon available under res/drawable-hdpi. The application uses the image named ic_launcher.png located in the drawable folders

The <activity> tag is used to specify an activity and android:name attribute specifies the fully qualified class name of the Activity subclass and the android:label attributes specifies a string to use as the label for the activity. You can specify multiple activities using <activity> tags.

The action for the intent filter is named android.intent.action.MAIN to indicate that this activity serves as the entry point for the application. The category for the intent-filter is named android.intent.category.LAUNCHER to indicate that the application can be launched from the device’s launcher icon.

The @string refers to the strings.xml file explained below. Hence, @string/app_name refers to the app_name string defined in the strings.xml file, which is “HelloWorld”. Similar way, other strings get populated in the application.

Following is the list of tags which you will use in your manifest file to specify different Android application components −

  • <activity>elements for activities
  • <service> elements for services
  • <receiver> elements for broadcast receivers
  • <provider> elements for content providers

The Strings File

The strings.xml file is located in the res/values folder and it contains all the text that your application uses. For example, the names of buttons, labels, default text, and similar types of strings go into this file. This file is responsible for their textual content. For example, a default strings file will look like as following file −

<resources>
   <string name="app_name">HelloWorld</string>
   <string name="hello_world">Hello world!</string>
   <string name="menu_settings">Settings</string>
   <string name="title_activity_main">MainActivity</string>
</resources>

The Layout File

The activity_main.xml is a layout file available in res/layout directory, that is referenced by your application when building its interface. You will modify this file very frequently to change the layout of your application. For your “Hello World!” application, this file will have following content related to default layout −

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   xmlns:tools="http://schemas.android.com/tools"
   android:layout_width="match_parent"
   android:layout_height="match_parent" >
   
   <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".MainActivity" />
      
</RelativeLayout>

This is an example of simple RelativeLayout which we will study in a separate chapter. The TextView is an Android control used to build the GUI and it have various attributes like android:layout_widthandroid:layout_height etc which are being used to set its width and height etc.. The @string refers to the strings.xml file located in the res/values folder. Hence, @string/hello_world refers to the hello string defined in the strings.xml file, which is “Hello World!”.

Running the Application

Let’s try to run our Hello World! application we just created. I assume you had created your AVD while doing environment set-up. To run the app from Android studio, open one of your project’s activity files and click Run Eclipse Run Icon icon from the tool bar. Android studio installs the app on your AVD and starts it and if everything is fine with your set-up and application, it will display following Emulator window −

Android Hello World

Congratulations!!! you have developed your first Android Application and now just keep following rest of the tutorial step by step to become a great Android Developer. All the very best.

source link

android Layouts & Drawable Resources in hindi

Introduction to Android Layouts 

जैसा की मैने आपको पहले बताया जब भी आप views क्रिएट करते है तो वो उसी order में शो होते है जिसमे आपने उन्हें क्रिएट किया है एक के बाद दूसरा। कई बार ऐसा हो सकता है की आप किसी view को screen पर एक particular position पर place करना चाहते है। ऐसा आप android layouts की मदद से कर सकते है।  

Layouts यूजर इंटरफ़ेस के लिए structure प्रोवाइड करते है उस structure के according आप अपने elements स्क्रीन पर मैनेज कर सकते है। Android system कई तरह के layouts provide करता है। आपकी एप्लीकेशन के लिए जो layout आपको ठीक लगे आप उसे यूज़ कर सकते है। https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-5239991314032243&output=html&h=280&slotname=4443653915&adk=2329325985&adf=3675991051&pi=t.ma~as.4443653915&w=725&fwrn=4&fwrnh=100&lmt=1649820167&rafmt=1&psa=1&format=725×280&url=https%3A%2F%2Fjavahindi.com%2F2021%2F05%2F26%2Fandroid-layouts-in-hindi%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiMi4wLjAiLCJ4ODYiLCIiLCIxMDAuMC40ODk2Ljc1IixbXSxudWxsLG51bGwsIjY0IixbWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDAuMC40ODk2Ljc1Il0sWyJHb29nbGUgQ2hyb21lIiwiMTAwLjAuNDg5Ni43NSJdXSxmYWxzZV0.&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbSIsInN0YXRlIjoyOSwiaGFzUmVkZW1wdGlvblJlY29yZCI6dHJ1ZX1d&dt=1649820155449&bpp=15&bdt=2047&idt=1038&shv=r20220406&mjsv=m202204040101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Dd13468a9c3377232-22ab5570eed100d8%3AT%3D1649840168%3ART%3D1649840168%3AS%3DALNI_MatDI3dIupxtx8kE8OPE81lZKDhRA&prev_fmts=0x0%2C1349x635%2C725x280&nras=2&correlator=7000724474451&frm=20&pv=1&ga_vid=1058618757.1649817694&ga_sid=1649820156&ga_hid=1498993617&ga_fc=1&u_tz=-420&u_his=1&u_h=768&u_w=1366&u_ah=738&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=165&ady=1707&biw=1349&bih=635&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C31061829%2C21067496%2C31062931&oid=2&pvsid=827520806363129&pem=880&tmod=1858317599&uas=0&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C738%2C1366%2C635&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=3&uci=a!3&btvi=2&fsb=1&xpc=zlYatsCQAa&p=https%3A//javahindi.com&dtd=11991

Android में layouts आप 2 तरह से define कर सकते है या तो आप एक XML फाइल के द्वारा ऐसा कर सकते है या run time  में view और view groups के objects क्रिएट करके ऐसा कर सकते है।   

आप जो चाहे वो तरीका अपना सकते है या आप दोनों तरीके भी अपना सकते है। आप चाहे तो XML के द्वारा क्रिएट किये हुए layouts को run time में चेंज भी कर सकते है। यदि आप layouts XML फाइल के द्वारा डिक्लेअर करते है तो आप अपनी एप्लीकेशन के view को और एप्लीकेशन के behavior को अलग अलग control कर सकते है।

Attributes of Android Layouts

नीचे कुछ common attributes दिए जा रहे है जो सभी views के साथ यूज़ होते है
android:id – इस attribute के द्वारा आप view की id define करते है जो view को uniquely identify करने के काम आती है।

android:layout_width – इस attribute के द्वारा आप view की screen पर width define करते है।

android:layout_height –  इस attribute के द्वारा आप view की स्क्रीन पर height define करते है।

Types of Android Layouts

Linear layout

Linear layout एक ऐसा layout है जिसमे सारे elements एक ही direction में होते है या तो vertical या horizontal. आप layout का direction android:orientation attribute के द्वारा define कर सकते है।

यदि layout का direction vertical है तो एक column में एक ही एलिमेंट आएगा। और यदि layout का direction horizontal है तो एक row में एक ही element आएगा।


यदि आप चाहे तो किसी एक particular element को priority वैल्यू भी दे सकते है। इसे layout weight कहते है।  ऐसा आप android:layout_weight attribute डिफाइन करके कर सकते है।  जिस element का जितना weight होता है वो उतना ही space screen पर cover करता है।

यदि किसी element का weight बाकि elements से अधिक है तो सभी elements के set होने के बाद जो remaining space होगा वो element cover करेगा।

Linear layout क्रिएट करने के लिए आपको XML file में <LinearLayout> element declare करना होगा। इस element के android:layout_width, android:layout_height और android:orientation 3 attributes होते है। इन तीनो attributes के लिए values provide करके आप layout को set कर सकते है।

  <LinearLayout xmlns:android="android schema address"  
android:layout_width="width of layout"
android:layout_height="height of layout"

android:orientation="layout orientation">
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:text="name of button" /> 
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:text="name of button" /> 
</LinearLayout>

Relative Layout

Relative layout view elements को relative positions पर display करता है। हर view को आप दूसरे elements के relation में position कर सकते है। किसी भी नए view की position आप existing view के relation में define करते है। जैसे की आप existing element के right में नए element को set करना चाहते है या left में। इस प्रकार आप किसी भी element को screen पर कँही भी place कर सकते है।

Relative layout views को position करने के लिए कुछ attributes provide करता है, जिनके द्वारा आप अपने view को position कर सकते है। आइये इन attributes के बारे में जानने का प्रयास करते है –

android:layout_alignParentTop

यदि किसी view element में इस attribute की value true है तो वो view आप की स्क्रीन में सबसे top पर show होगा।

android:layout_centralVertical   

यदि किसी view element में इस attribute की वैल्यू true है तो वो view आप की स्क्रीन में vertically center में show होगा।

android:layout_below

ये attribute आपके view element को उस view के नीचे position करता है जो आपने resource id के द्वारा define किया है।

android:layout_toRightOf

ये attribute आपके view element को उस view element के right में place करता है जो आपने resource id के द्वारा define किया है।

यँहा पर ये कुछ उदाहरण दिए गए है ये attributes बहुत सारे है। आप जो चाहे अपनी आवश्यकता के अनुसार इस्तेमाल कर सकते है।

  <RelativeLayout xmlns:android="android schema address"  
android:layout_width="width of layout"
android:layout_height="height of layout"
android:paddingLeft="in dp"
android:paddingRight="in dp">

<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:layout_below="id of other view element"
andorid:text="name of button" /> 
<Button
android:layout_width="width of button"
android:layout_height="height of button"
android:layout_centralVertical="id of other view element"
android:text="name of button" /> 
</RelativeLayout>

ListView

https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-5239991314032243&output=html&h=280&slotname=4443653915&adk=2329325985&adf=3177732490&pi=t.ma~as.4443653915&w=725&fwrn=4&fwrnh=100&lmt=1649820187&rafmt=1&psa=1&format=725×280&url=https%3A%2F%2Fjavahindi.com%2F2021%2F05%2F26%2Fandroid-layouts-in-hindi%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiMi4wLjAiLCJ4ODYiLCIiLCIxMDAuMC40ODk2Ljc1IixbXSxudWxsLG51bGwsIjY0IixbWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDAuMC40ODk2Ljc1Il0sWyJHb29nbGUgQ2hyb21lIiwiMTAwLjAuNDg5Ni43NSJdXSxmYWxzZV0.&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbSIsInN0YXRlIjoyOSwiaGFzUmVkZW1wdGlvblJlY29yZCI6dHJ1ZX1d&dt=1649820155502&bpp=4&bdt=2101&idt=995&shv=r20220406&mjsv=m202204040101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Dd13468a9c3377232-22ab5570eed100d8%3AT%3D1649840168%3ART%3D1649840168%3AS%3DALNI_MatDI3dIupxtx8kE8OPE81lZKDhRA&prev_fmts=0x0%2C1349x635%2C725x280%2C725x280%2C195x600%2C195x240%2C195x240&nras=5&correlator=7000724474451&frm=20&pv=1&ga_vid=1058618757.1649817694&ga_sid=1649820156&ga_hid=1498993617&ga_fc=1&u_tz=-420&u_his=1&u_h=768&u_w=1366&u_ah=738&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=165&ady=5253&biw=1349&bih=635&scr_x=0&scr_y=2732&eid=44759875%2C44759926%2C44759842%2C31061829%2C21067496%2C31062931&oid=2&psts=AGkb-H_iANaidqCbecBi2coY9nxwoYmHLS9VeahWlz_Wpv9E03llRq_Rdzj2WMtKKtbYICWMy5WBHJb4dYpidWt4KA%2CAGkb-H_4f8Qhvs9SS9VooAJVjZiPmpnh0I4O2eAgbVK16an5K-R6ATak_QnzOW7fP7JYkunUcO_5TNQuoLFumLp7uA%2CAGkb-H_-zbliZRpos9thGXrtQCXtobi9gCJb5rOPYe61O6qeblHX6MoIYHVr0Gt31u6hiakoBFjoOKiFRIuZHpDAUQ%2CAGkb-H-i424EdrVbuYd9IeB6r_ZrT4yUnnyr3DTPN8imTuQKcH22vaDE4LwmuVjmOQUxzRqxoAsywlkJOXol44XVwQ&pvsid=827520806363129&pem=880&tmod=1858317599&uas=1&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C738%2C1366%2C635&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=4&uci=a!4&btvi=6&fsb=1&xpc=J7BJsuPkNP&p=https%3A//javahindi.com&dtd=32384

ListView एक view group होता है जो items की list show करता है जिन्हे आप scroll कर सकते है। ये layout run time में सभी views को मैनेज कर सकता है। इस layout में एक ही column होता है और row बहुत सी होती है। यानी आप एक row में एक ही view position कर सकते है।

Run time में आप adapter के द्वारा किसी array या database से item को pull करते है वो adapter उस item को view convert करके list के आखिर में add कर देता है।

GridView

GridView एक view group होता है तो items को two dimensional grid में शो करता है। इस grid को आप scroll कर सकते है। इस layout में items rows और columns की form में show होते है।  GridView में items run time पर automatically insert हो जाते है।

Drawable resources

A drawable resource is a general concept for a graphic that can be drawn to the screen and which you can retrieve with APIs such as getDrawable(int) or apply to another XML resource with attributes such as android:drawable and android:icon. There are several different types of drawables:Bitmap FileA bitmap graphic file (.png.webp.jpg, or .gif). Creates a BitmapDrawable.Nine-Patch FileA PNG file with stretchable regions to allow image resizing based on content (.9.png). Creates a NinePatchDrawable.Layer ListA Drawable that manages an array of other Drawables. These are drawn in array order, so the element with the largest index is be drawn on top. Creates a LayerDrawable.State ListAn XML file that references different bitmap graphics for different states (for example, to use a different image when a button is pressed). Creates a StateListDrawable.Level ListAn XML file that defines a drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Creates a LevelListDrawable.Transition DrawableAn XML file that defines a drawable that can cross-fade between two drawable resources. Creates a TransitionDrawable.Inset DrawableAn XML file that defines a drawable that insets another drawable by a specified distance. This is useful when a View needs a background drawable that is smaller than the View’s actual bounds.Clip DrawableAn XML file that defines a drawable that clips another Drawable based on this Drawable’s current level value. Creates a ClipDrawable.Scale DrawableAn XML file that defines a drawable that changes the size of another Drawable based on its current level value. Creates a ScaleDrawableShape DrawableAn XML file that defines a geometric shape, including colors and gradients. Creates a GradientDrawable.

Also see the Animation Resource document for how to create an AnimationDrawable.

Note: A color resource can also be used as a drawable in XML. For example, when creating a state list drawable, you can reference a color resource for the android:drawable attribute (android:drawable="@color/green").

Bitmap

A bitmap image. Android supports bitmap files in the following formats: .png (preferred), ,webp (preferred, requires API level 17 or higher), .jpg (acceptable), .gif (discouraged).

You can reference a bitmap file directly, using the filename as the resource ID, or create an alias resource ID in XML.

Note: Bitmap files may be automatically optimized with lossless image compression by the aapt tool during the build process. For example, a true-color PNG that does not require more than 256 colors may be converted to an 8-bit PNG with a color palette. This will result in an image of equal quality but which requires less memory. So be aware that the image binaries placed in this directory can change during the build. If you plan on reading an image as a bit stream in order to convert it to a bitmap, put your images in the res/raw/ folder instead, where they will not be optimized.

Bitmap file

A bitmap file is a .png.webp.jpg, or .gif file. Android creates a Drawable resource for any of these files when you save them in the res/drawable/ directory.file location:res/drawable/filename.png (.png.webp.jpg, or .gif)
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a BitmapDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenameexample:With an image saved at res/drawable/myimage.png, this layout XML applies the image to a View:

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/myimage" />

The following application code retrieves the image as a Drawable:KotlinJava

val drawable: Drawable? = ResourcesCompat.getDrawable(resources, R.drawable.myimage, null)

see also:

XML bitmap

An XML bitmap is a resource defined in XML that points to a bitmap file. The effect is an alias for a raw bitmap file. The XML can specify additional properties for the bitmap such as dithering and tiling.

Note: You can use a <bitmap> element as a child of an <item> element. For example, when creating a state list or layer list, you can exclude the android:drawable attribute from an <item> element and nest a <bitmap> inside it that defines the drawable item.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a BitmapDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<bitmap
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@[package:]drawable/drawable_resource"
    android:antialias=["true" | "false"]
    android:dither=["true" | "false"]
    android:filter=["true" | "false"]
    android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                      "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                      "center" | "fill" | "clip_vertical" | "clip_horizontal"]
    android:mipMap=["true" | "false"]
    android:tileMode=["disabled" | "clamp" | "repeat" | "mirror"] />

elements:<bitmap>Defines the bitmap source and its properties.

attributes:xmlns:androidString. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android". This is required only if the <bitmap> is the root element—it is not needed when the <bitmap> is nested inside an <item>.android:srcDrawable resourceRequired. Reference to a drawable resource.android:antialiasBoolean. Enables or disables antialiasing.android:ditherBoolean. Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen).android:filterBoolean. Enables or disables bitmap filtering. Filtering is used when the bitmap is shrunk or stretched to smooth its apperance.android:gravityKeyword. Defines the gravity for the bitmap. The gravity indicates where to position the drawable in its container if the bitmap is smaller than the container.

Must be one or more (separated by ‘|’) of the following constant values:

ValueDescription
topPut the object at the top of its container, not changing its size.
bottomPut the object at the bottom of its container, not changing its size.
leftPut the object at the left edge of its container, not changing its size.
rightPut the object at the right edge of its container, not changing its size.
center_verticalPlace object in the vertical center of its container, not changing its size.
fill_verticalGrow the vertical size of the object if needed so it completely fills its container.
center_horizontalPlace object in the horizontal center of its container, not changing its size.
fill_horizontalGrow the horizontal size of the object if needed so it completely fills its container.
centerPlace the object in the center of its container in both the vertical and horizontal axis, not changing its size.
fillGrow the horizontal and vertical size of the object if needed so it completely fills its container. This is the default.
clip_verticalAdditional option that can be set to have the top and/or bottom edges of the child clipped to its container’s bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
clip_horizontalAdditional option that can be set to have the left and/or right edges of the child clipped to its container’s bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.

android:mipMapBoolean. Enables or disables the mipmap hint. See setHasMipMap() for more information. Default value is false.android:tileModeKeyword. Defines the tile mode. When the tile mode is enabled, the bitmap is repeated. Gravity is ignored when the tile mode is enabled.

Must be one of the following constant values:

ValueDescription
disabledDo not tile the bitmap. This is the default value.
clampReplicates the edge color if the shader draws outside of its original bounds
repeatRepeats the shader’s image horizontally and vertically.
mirrorRepeats the shader’s image horizontally and vertically, alternating mirror images so that adjacent images always seam.

example:

<?xml version="1.0" encoding="utf-8"?>
<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/icon"
    android:tileMode="repeat" />

see also:

Nine-Patch

NinePatch is a PNG image in which you can define stretchable regions that Android scales when content within the View exceeds the normal image bounds. You typically assign this type of image as the background of a View that has at least one dimension set to "wrap_content", and when the View grows to accommodate the content, the Nine-Patch image is also scaled to match the size of the View. An example use of a Nine-Patch image is the background used by Android’s standard Button widget, which must stretch to accommodate the text (or image) inside the button.

Same as with a normal bitmap, you can reference a Nine-Patch file directly or from a resource defined by XML.

For a complete discussion about how to create a Nine-Patch file with stretchable regions, see the 2D Graphics document.

Nine-patch file

file location:res/drawable/filename.9.png
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a NinePatchDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenameexample:With an image saved at res/drawable/myninepatch.9.png, this layout XML applies the Nine-Patch to a View:

<Button
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/myninepatch" />

see also:

XML Nine-Patch

An XML Nine-Patch is a resource defined in XML that points to a Nine-Patch file. The XML can specify dithering for the image.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a NinePatchDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<nine-patch
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@[package:]drawable/drawable_resource"
    android:dither=["true" | "false"] />

elements:<nine-patch>Defines the Nine-Patch source and its properties.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:srcDrawable resourceRequired. Reference to a Nine-Patch file.android:ditherBoolean. Enables or disables dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance: a ARGB 8888 bitmap with an RGB 565 screen).example:

<?xml version="1.0" encoding="utf-8"?>
<nine-patch xmlns:android="http://schemas.android.com/apk/res/android"
    android:src="@drawable/myninepatch"
    android:dither="false" />

Layer list

LayerDrawable is a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.

Each drawable is represented by an <item> element inside a single <layer-list> element.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a LayerDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<layer-list
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@[package:]drawable/drawable_resource"
        android:id="@[+][package:]id/resource_name"
        android:top="dimension"
        android:right="dimension"
        android:bottom="dimension"
        android:left="dimension" />
</layer-list>

elements:<layer-list>Required. This must be the root element. Contains one or more <item> elements.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".<item>Defines a drawable to place in the layer drawable, in a position defined by its attributes. Must be a child of a <layer-list> element. Accepts child <bitmap> elements.

attributes:android:drawableDrawable resourceRequired. Reference to a drawable resource.android:idResource ID. A unique resource ID for this drawable. To create a new resource ID for this item, use the form: "@+id/name". The plus symbol indicates that this should be created as a new ID. You can use this identifier to retrieve and modify the drawable with View.findViewById() or Activity.findViewById().android:topDimension. The top offset, as a dimension value or dimension resource.android:rightDimension. The right offset, as a dimension value or dimension resource.android:bottomDimension. The bottom offset, as a dimension value or dimension resource.android:leftDimension. The left offset, as a dimension value or dimension resource.

All drawable items are scaled to fit the size of the containing View, by default. Thus, placing your images in a layer list at different positions might increase the size of the View and some images scale as appropriate. To avoid scaling items in the list, use a <bitmap> element inside the <item> element to specify the drawable and define the gravity to something that does not scale, such as "center". For example, the following <item> defines an item that scales to fit its container View:

<item android:drawable="@drawable/image" />

To avoid scaling, the following example uses a <bitmap> element with centered gravity:

<item>
  <bitmap android:src="@drawable/image"
          android:gravity="center" />
</item>

example:XML file saved at res/drawable/layers.xml:

<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
    <item>
      <bitmap android:src="@drawable/android_red"
        android:gravity="center" />
    </item>
    <item android:top="10dp" android:left="10dp">
      <bitmap android:src="@drawable/android_green"
        android:gravity="center" />
    </item>
    <item android:top="20dp" android:left="20dp">
      <bitmap android:src="@drawable/android_blue"
        android:gravity="center" />
    </item>
</layer-list>

Notice that this example uses a nested <bitmap> element to define the drawable resource for each item with a “center” gravity. This ensures that none of the images are scaled to fit the size of the container, due to resizing caused by the offset images.

This layout XML applies the drawable to a View:

<ImageView
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/layers" />

The result is a stack of increasingly offset images:see also:

State list

StateListDrawable is a drawable object defined in XML that uses a several different images to represent the same graphic, depending on the state of the object. For example, a Button widget can exist in one of several different states (pressed, focused, or neither) and, using a state list drawable, you can provide a different background image for each state.

You can describe the state list in an XML file. Each graphic is represented by an <item> element inside a single <selector> element. Each <item> uses various attributes to describe the state in which it should be used as the graphic for the drawable.

During each state change, the state list is traversed top to bottom and the first item that matches the current state is used—the selection is not based on the “best match,” but simply the first item that meets the minimum criteria of the state.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a StateListDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
    android:constantSize=["true" | "false"]
    android:dither=["true" | "false"]
    android:variablePadding=["true" | "false"] >
    <item
        android:drawable="@[package:]drawable/drawable_resource"
        android:state_pressed=["true" | "false"]
        android:state_focused=["true" | "false"]
        android:state_hovered=["true" | "false"]
        android:state_selected=["true" | "false"]
        android:state_checkable=["true" | "false"]
        android:state_checked=["true" | "false"]
        android:state_enabled=["true" | "false"]
        android:state_activated=["true" | "false"]
        android:state_window_focused=["true" | "false"] />
</selector>

elements:<selector>Required. This must be the root element. Contains one or more <item> elements.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:constantSizeBoolean. “true” if the drawable’s reported internal size remains constant as the state changes (the size is the maximum of all of the states); “false” if the size varies based on the current state. Default is false.android:ditherBoolean. “true” to enable dithering of the bitmap if the bitmap does not have the same pixel configuration as the screen (for instance, an ARGB 8888 bitmap with an RGB 565 screen); “false” to disable dithering. Default is true.android:variablePaddingBoolean. “true” if the drawable’s padding should change based on the current state that is selected; “false” if the padding should stay the same (based on the maximum padding of all the states). Enabling this feature requires that you deal with performing layout when the state changes, which is often not supported. Default is false.<item>Defines a drawable to use during certain states, as described by its attributes. Must be a child of a <selector> element.

attributes:android:drawableDrawable resourceRequired. Reference to a drawable resource.android:state_pressedBoolean. “true” if this item should be used when the object is pressed (such as when a button is touched/clicked); “false” if this item should be used in the default, non-pressed state.android:state_focusedBoolean. “true” if this item should be used when the object has input focus (such as when the user selects a text input); “false” if this item should be used in the default, non-focused state.android:state_hoveredBoolean. “true” if this item should be used when the object is being hovered by a cursor; “false” if this item should be used in the default, non-hovered state. Often, this drawable may be the same drawable used for the “focused” state.

Introduced in API level 14.android:state_selectedBoolean. “true” if this item should be used when the object is the current user selection when navigating with a directional control (such as when navigating through a list with a d-pad); “false” if this item should be used when the object is not selected.

The selected state is used when focus (android:state_focused) is not sufficient (such as when list view has focus and an item within it is selected with a d-pad).android:state_checkableBoolean. “true” if this item should be used when the object is checkable; “false” if this item should be used when the object is not checkable. (Only useful if the object can transition between a checkable and non-checkable widget.)android:state_checkedBoolean. “true” if this item should be used when the object is checked; “false” if it should be used when the object is un-checked.android:state_enabledBoolean. “true” if this item should be used when the object is enabled (capable of receiving touch/click events); “false” if it should be used when the object is disabled.android:state_activatedBoolean. “true” if this item should be used when the object is activated as the persistent selection (such as to “highlight” the previously selected list item in a persistent navigation view); “false” if it should be used when the object is not activated.

Introduced in API level 11.android:state_window_focusedBoolean. “true” if this item should be used when the application window has focus (the application is in the foreground), “false” if this item should be used when the application window does not have focus (for example, if the notification shade is pulled down or a dialog appears).

Note: Remember that Android applies the first item in the state list that matches the current state of the object. So, if the first item in the list contains none of the state attributes above, then it is applied every time, which is why your default value should always be last (as demonstrated in the following example).example:XML file saved at res/drawable/button.xml:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
          android:drawable="@drawable/button_pressed" /> <!-- pressed -->
    <item android:state_focused="true"
          android:drawable="@drawable/button_focused" /> <!-- focused -->
    <item android:state_hovered="true"
          android:drawable="@drawable/button_focused" /> <!-- hovered -->
    <item android:drawable="@drawable/button_normal" /> <!-- default -->
</selector>

This layout XML applies the state list drawable to a Button:

<Button
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:background="@drawable/button" />

see also:

Level list

A Drawable that manages a number of alternate Drawables, each assigned a maximum numerical value. Setting the level value of the drawable with setLevel() loads the drawable resource in the level list that has a android:maxLevel value greater than or equal to the value passed to the method.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a LevelListDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<level-list
    xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@drawable/drawable_resource"
        android:maxLevel="integer"
        android:minLevel="integer" />
</level-list>

elements:<level-list>This must be the root element. Contains one or more <item> elements.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".<item>Defines a drawable to use at a certain level.

attributes:android:drawableDrawable resourceRequired. Reference to a drawable resource to be inset.android:maxLevelInteger. The maximum level allowed for this item.android:minLevelInteger. The minimum level allowed for this item.example:

<?xml version="1.0" encoding="utf-8"?>
<level-list xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@drawable/status_off"
        android:maxLevel="0" />
    <item
        android:drawable="@drawable/status_on"
        android:maxLevel="1" />
</level-list>

Once this is applied to a View, the level can be changed with setLevel() or setImageLevel().see also:

Transition drawable

TransitionDrawable is a drawable object that can cross-fade between the two drawable resources.

Each drawable is represented by an <item> element inside a single <transition> element. No more than two items are supported. To transition forward, call startTransition(). To transition backward, call reverseTransition().file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a TransitionDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<transition
xmlns:android="http://schemas.android.com/apk/res/android" >
    <item
        android:drawable="@[package:]drawable/drawable_resource"
        android:id="@[+][package:]id/resource_name"
        android:top="dimension"
        android:right="dimension"
        android:bottom="dimension"
        android:left="dimension" />
</transition>

elements:<transition>Required. This must be the root element. Contains one or more <item> elements.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".<item>Defines a drawable to use as part of the drawable transition. Must be a child of a <transition> element. Accepts child <bitmap> elements.

attributes:android:drawableDrawable resourceRequired. Reference to a drawable resource.android:idResource ID. A unique resource ID for this drawable. To create a new resource ID for this item, use the form: "@+id/name". The plus symbol indicates that this should be created as a new ID. You can use this identifier to retrieve and modify the drawable with View.findViewById() or Activity.findViewById().android:topInteger. The top offset in pixels.android:rightInteger. The right offset in pixels.android:bottomInteger. The bottom offset in pixels.android:leftInteger. The left offset in pixels.example:XML file saved at res/drawable/transition.xml:

<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:drawable="@drawable/on" />
    <item android:drawable="@drawable/off" />
</transition>

This layout XML applies the drawable to a View:

<ImageButton
    android:id="@+id/button"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content"
    android:src="@drawable/transition" />

And the following code performs a 500ms transition from the first item to the second:KotlinJava

val button: ImageButton = findViewById(R.id.button)
val drawable: Drawable = button.drawable
if (drawable is TransitionDrawable) {
    drawable.startTransition(500)
}

see also:

Inset drawable

A drawable defined in XML that insets another drawable by a specified distance. This is useful when a View needs a background that is smaller than the View’s actual bounds.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a InsetDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<inset
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/drawable_resource"
    android:insetTop="dimension"
    android:insetRight="dimension"
    android:insetBottom="dimension"
    android:insetLeft="dimension" />

elements:<inset>Defines the inset drawable. This must be the root element.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:drawableDrawable resourceRequired. Reference to a drawable resource to be inset.android:insetTopDimension. The top inset, as a dimension value or dimension resourceandroid:insetRightDimension. The right inset, as a dimension value or dimension resourceandroid:insetBottomDimension. The bottom inset, as a dimension value or dimension resourceandroid:insetLeftDimension. The left inset, as a dimension value or dimension resourceexample:

<?xml version="1.0" encoding="utf-8"?>
<inset xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/background"
    android:insetTop="10dp"
    android:insetLeft="10dp" />

see also:

Clip drawable

A drawable defined in XML that clips another drawable based on this Drawable’s current level. You can control how much the child drawable gets clipped in width and height based on the level, as well as a gravity to control where it is placed in its overall container. Most often used to implement things like progress bars.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a ClipDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<clip
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/drawable_resource"
    android:clipOrientation=["horizontal" | "vertical"]
    android:gravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                     "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                     "center" | "fill" | "clip_vertical" | "clip_horizontal"] />

elements:<clip>Defines the clip drawable. This must be the root element.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:drawableDrawable resourceRequired. Reference to a drawable resource to be clipped.android:clipOrientationKeyword. The orientation for the clip.

Must be one of the following constant values:

ValueDescription
horizontalClip the drawable horizontally.
verticalClip the drawable vertically.

android:gravityKeyword. Specifies where to clip within the drawable.

Must be one or more (separated by ‘|’) of the following constant values:

ValueDescription
topPut the object at the top of its container, not changing its size. When clipOrientation is "vertical", clipping occurs at the bottom of the drawable.
bottomPut the object at the bottom of its container, not changing its size. When clipOrientation is "vertical", clipping occurs at the top of the drawable.
leftPut the object at the left edge of its container, not changing its size. This is the default. When clipOrientation is "horizontal", clipping occurs at the right side of the drawable. This is the default.
rightPut the object at the right edge of its container, not changing its size. When clipOrientation is "horizontal", clipping occurs at the left side of the drawable.
center_verticalPlace object in the vertical center of its container, not changing its size. Clipping behaves the same as when gravity is "center".
fill_verticalGrow the vertical size of the object if needed so it completely fills its container. When clipOrientation is "vertical", no clipping occurs because the drawable fills the vertical space (unless the drawable level is 0, in which case it’s not visible).
center_horizontalPlace object in the horizontal center of its container, not changing its size. Clipping behaves the same as when gravity is "center".
fill_horizontalGrow the horizontal size of the object if needed so it completely fills its container. When clipOrientation is "horizontal", no clipping occurs because the drawable fills the horizontal space (unless the drawable level is 0, in which case it’s not visible).
centerPlace the object in the center of its container in both the vertical and horizontal axis, not changing its size. When clipOrientation is "horizontal", clipping occurs on the left and right. When clipOrientation is "vertical", clipping occurs on the top and bottom.
fillGrow the horizontal and vertical size of the object if needed so it completely fills its container. No clipping occurs because the drawable fills the horizontal and vertical space (unless the drawable level is 0, in which case it’s not visible).
clip_verticalAdditional option that can be set to have the top and/or bottom edges of the child clipped to its container’s bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
clip_horizontalAdditional option that can be set to have the left and/or right edges of the child clipped to its container’s bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.

example:XML file saved at res/drawable/clip.xml:

<?xml version="1.0" encoding="utf-8"?>
<clip xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/android"
    android:clipOrientation="horizontal"
    android:gravity="left" />

The following layout XML applies the clip drawable to a View:

<ImageView
    android:id="@+id/image"
    android:src="@drawable/clip"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" />

The following code gets the drawable and increases the amount of clipping in order to progressively reveal the image:KotlinJava

val imageview: ImageView = findViewById(R.id.image)
val drawable: Drawable = imageview.background
if (drawable is ClipDrawable) {
    drawable.level = drawable.level + 1000
}

Increasing the level reduces the amount of clipping and slowly reveals the image. Here it is at a level of 7000:

Note: The default level is 0, which is fully clipped so the image is not visible. When the level is 10,000, the image is not clipped and completely visible.see also:

Scale drawable

A drawable defined in XML that changes the size of another drawable based on its current level.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a ScaleDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<scale
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/drawable_resource"
    android:scaleGravity=["top" | "bottom" | "left" | "right" | "center_vertical" |
                          "fill_vertical" | "center_horizontal" | "fill_horizontal" |
                          "center" | "fill" | "clip_vertical" | "clip_horizontal"]
    android:scaleHeight="percentage"
    android:scaleWidth="percentage" />

elements:<scale>Defines the scale drawable. This must be the root element.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:drawableDrawable resourceRequired. Reference to a drawable resource.android:scaleGravityKeyword. Specifies the gravity position after scaling.

Must be one or more (separated by ‘|’) of the following constant values:

ValueDescription
topPut the object at the top of its container, not changing its size.
bottomPut the object at the bottom of its container, not changing its size.
leftPut the object at the left edge of its container, not changing its size. This is the default.
rightPut the object at the right edge of its container, not changing its size.
center_verticalPlace object in the vertical center of its container, not changing its size.
fill_verticalGrow the vertical size of the object if needed so it completely fills its container.
center_horizontalPlace object in the horizontal center of its container, not changing its size.
fill_horizontalGrow the horizontal size of the object if needed so it completely fills its container.
centerPlace the object in the center of its container in both the vertical and horizontal axis, not changing its size.
fillGrow the horizontal and vertical size of the object if needed so it completely fills its container.
clip_verticalAdditional option that can be set to have the top and/or bottom edges of the child clipped to its container’s bounds. The clip is based on the vertical gravity: a top gravity clips the bottom edge, a bottom gravity clips the top edge, and neither clips both edges.
clip_horizontalAdditional option that can be set to have the left and/or right edges of the child clipped to its container’s bounds. The clip is based on the horizontal gravity: a left gravity clips the right edge, a right gravity clips the left edge, and neither clips both edges.

android:scaleHeightPercentage. The scale height, expressed as a percentage of the drawable’s bound. The value’s format is XX%. For instance: 100%, 12.5%, etc.android:scaleWidthPercentage. The scale width, expressed as a percentage of the drawable’s bound. The value’s format is XX%. For instance: 100%, 12.5%, etc.example:

<?xml version="1.0" encoding="utf-8"?>
<scale xmlns:android="http://schemas.android.com/apk/res/android"
    android:drawable="@drawable/logo"
    android:scaleGravity="center_vertical|center_horizontal"
    android:scaleHeight="80%"
    android:scaleWidth="80%" />

see also:

Shape drawable

This is a generic shape defined in XML.file location:res/drawable/filename.xml
The filename is used as the resource ID.compiled resource datatype:Resource pointer to a GradientDrawable.resource reference:In Java: R.drawable.filename
In XML: @[package:]drawable/filenamesyntax:

<?xml version="1.0" encoding="utf-8"?>
<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape=["rectangle" | "oval" | "line" | "ring"] >
    <corners
        android:radius="integer"
        android:topLeftRadius="integer"
        android:topRightRadius="integer"
        android:bottomLeftRadius="integer"
        android:bottomRightRadius="integer" />
    <gradient
        android:angle="integer"
        android:centerX="float"
        android:centerY="float"
        android:centerColor="integer"
        android:endColor="color"
        android:gradientRadius="integer"
        android:startColor="color"
        android:type=["linear" | "radial" | "sweep"]
        android:useLevel=["true" | "false"] />
    <padding
        android:left="integer"
        android:top="integer"
        android:right="integer"
        android:bottom="integer" />
    <size
        android:width="integer"
        android:height="integer" />
    <solid
        android:color="color" />
    <stroke
        android:width="integer"
        android:color="color"
        android:dashWidth="integer"
        android:dashGap="integer" />
</shape>

elements:<shape>The shape drawable. This must be the root element.

attributes:xmlns:androidStringRequired. Defines the XML namespace, which must be "http://schemas.android.com/apk/res/android".android:shapeKeyword. Defines the type of shape. Valid values are:

ValueDesciption
"rectangle"A rectangle that fills the containing View. This is the default shape.
"oval"An oval shape that fits the dimensions of the containing View.
"line"A horizontal line that spans the width of the containing View. This shape requires the <stroke> element to define the width of the line.
"ring"A ring shape.

The following attributes are used only when android:shape="ring":android:innerRadiusDimension. The radius for the inner part of the ring (the hole in the middle), as a dimension value or dimension resource.android:innerRadiusRatioFloat. The radius for the inner part of the ring, expressed as a ratio of the ring’s width. For instance, if android:innerRadiusRatio="5", then the inner radius equals the ring’s width divided by 5. This value is overridden by android:innerRadius. Default value is 9.android:thicknessDimension. The thickness of the ring, as a dimension value or dimension resource.android:thicknessRatioFloat. The thickness of the ring, expressed as a ratio of the ring’s width. For instance, if android:thicknessRatio="2", then the thickness equals the ring’s width divided by 2. This value is overridden by android:innerRadius. Default value is 3.android:useLevelBoolean. “true” if this is used as a LevelListDrawable. This should normally be “false” or your shape may not appear.<corners>Creates rounded corners for the shape. Applies only when the shape is a rectangle.

attributes:android:radiusDimension. The radius for all corners, as a dimension value or dimension resource. This is overridden for each corner by the following attributes.android:topLeftRadiusDimension. The radius for the top-left corner, as a dimension value or dimension resource.android:topRightRadiusDimension. The radius for the top-right corner, as a dimension value or dimension resource.android:bottomLeftRadiusDimension. The radius for the bottom-left corner, as a dimension value or dimension resource.android:bottomRightRadiusDimension. The radius for the bottom-right corner, as a dimension value or dimension resource.

Note: Every corner must (initially) be provided a corner radius greater than 1, or else no corners are rounded. If you want specific corners to not be rounded, a work-around is to use android:radius to set a default corner radius greater than 1, but then override each and every corner with the values you really want, providing zero (“0dp”) where you don’t want rounded corners.<gradient>Specifies a gradient color for the shape.

attributes:android:angleInteger. The angle for the gradient, in degrees. 0 is left to right, 90 is bottom to top. It must be a multiple of 45. Default is 0.android:centerXFloat. The relative X-position for the center of the gradient (0 – 1.0).android:centerYFloat. The relative Y-position for the center of the gradient (0 – 1.0).android:centerColorColor. Optional color that comes between the start and end colors, as a hexadecimal value or color resource.android:endColorColor. The ending color, as a hexadecimal value or color resource.android:gradientRadiusFloat. The radius for the gradient. Only applied when android:type="radial".android:startColorColor. The starting color, as a hexadecimal value or color resource.android:typeKeyword. The type of gradient pattern to apply. Valid values are:

ValueDescription
"linear"A linear gradient. This is the default.
"radial"A radial gradient. The start color is the center color.
"sweep"A sweeping line gradient.

android:useLevelBoolean. “true” if this is used as a LevelListDrawable.<padding>Padding to apply to the containing View element (this pads the position of the View content, not the shape).

attributes:android:leftDimension. Left padding, as a dimension value or dimension resource.android:topDimension. Top padding, as a dimension value or dimension resource.android:rightDimension. Right padding, as a dimension value or dimension resource.android:bottomDimension. Bottom padding, as a dimension value or dimension resource.<size>The size of the shape.

attributes:android:heightDimension. The height of the shape, as a dimension value or dimension resource.android:widthDimension. The width of the shape, as a dimension value or dimension resource.

Note: The shape scales to the size of the container View proportionate to the dimensions defined here, by default. When you use the shape in an ImageView, you can restrict scaling by setting the android:scaleType to "center".<solid>A solid color to fill the shape.

attributes:android:colorColor. The color to apply to the shape, as a hexadecimal value or color resource.<stroke>A stroke line for the shape.

attributes:android:widthDimension. The thickness of the line, as a dimension value or dimension resource.android:colorColor. The color of the line, as a hexadecimal value or color resource.android:dashGapDimension. The distance between line dashes, as a dimension value or dimension resource. Only valid if android:dashWidth is set.android:dashWidthDimension. The size of each dash line, as a dimension value or dimension resource. Only valid if android:dashGap is set.example:XML file saved at res/drawable/gradient_box.xml:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <gradient
        android:startColor="#FFFF0000"
        android:endColor="#80FF00FF"
        android:angle="45"/>
    <padding android:left="7dp"
        android:top="7dp"
        android:right="7dp"
        android:bottom="7dp" />
    <corners android:radius="8dp" />
</shape>

This layout XML applies the shape drawable to a View:

<TextView
    android:background="@drawable/gradient_box"
    android:layout_height="wrap_content"
    android:layout_width="wrap_content" />

This application code gets the shape drawable and applies it to a View:KotlinJava

val shape: Drawable? = getDrawable(resources, R.drawable.gradient_box, getTheme())

val tv: TextView = findViewById(R.id.textview)
tv.background = shape

source link

android Assets in hindi

android में assets एक फोल्डर होता है जो एंड्राइड में ऑफलाइन फाइल या डॉक्यूमेंट txt etc फाइल को स्टोर करता है

एंड्राइड assets में raw डॉक्यूमेंट को स्टोर किया जाता है एंड्राइड में किसी एबूक के पीडीऍफ़ लाइफ को acess करने के लिए

Step 1: To create an asset folder in Android studio open your project in Android mode first as shown in the below image. Step 2: Go to the app > right-click > New > Folder > Asset Folder and create the asset folder. Step 3: Android Studio will open a dialog box. Keep all the settings default.

How To Add/Create Assets Folder In Android Studio For HTML Files

You might have noticed that unlike Eclipse ADT Android Studio doesn’t have Assets folder which we usually use to keep our web files like HTML. Assets folder is saved under main folder: main/assets:

Here we will share step by step how to create Assets raw folder in Android Studio.


How to add assets and raw folder in android Studio

Step 1: Open your android studio. Navigate to Android option.

android option android studio

Step 2: You will find app folder and Gradle Script. Right click on app folder goto New> Folder>Assets Folder.

Assets Folder in Android Studio

Step 3: Android Studio will open a dialog box. Keep all the settings default. Under target source set, option main should be selected. and click finish.

target source set main in Assets Folder

Step 4: Now open app folder. you will find your Assets folder by the name of “assets”.https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-7694781728609715&output=html&h=280&slotname=1910981465&adk=1282101398&adf=2491534423&pi=t.ma~as.1910981465&w=336&lmt=1649819983&psa=0&format=336×280&url=https%3A%2F%2Fabhiandroid.com%2Fandroidstudio%2Fcreate-assets-folder-android-studio-html-files.html&wgl=1&uach=WyJXaW5kb3dzIiwiMi4wLjAiLCJ4ODYiLCIiLCIxMDAuMC40ODk2Ljc1IixbXSxudWxsLG51bGwsIjY0IixbWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDAuMC40ODk2Ljc1Il0sWyJHb29nbGUgQ2hyb21lIiwiMTAwLjAuNDg5Ni43NSJdXSxmYWxzZV0.&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbSIsInN0YXRlIjoyMCwiaGFzUmVkZW1wdGlvblJlY29yZCI6dHJ1ZX1d&dt=1649819981152&bpp=3&bdt=2616&idt=1901&shv=r20220406&mjsv=m202204040101&ptt=9&saldr=aa&abxe=1&prev_fmts=0x0%2C728x90&nras=1&correlator=2393598650449&frm=20&pv=1&ga_vid=981562457.1649819982&ga_sid=1649819983&ga_hid=1635780644&ga_fc=1&u_tz=-420&u_his=7&u_h=768&u_w=1366&u_ah=738&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=292&ady=1512&biw=1349&bih=635&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C44760475%2C31065742%2C21067496&oid=2&pvsid=2390461340193287&pem=715&tmod=1265627639&uas=0&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C738%2C1366%2C635&vis=1&rsz=o%7C%7CeEbr%7C&abl=CS&pfx=0&fu=0&bc=31&ifi=3&uci=a!3&btvi=1&fsb=1&xpc=5K6TOFsYie&p=https%3A//abhiandroid.com&dtd=1929

Assets Folder Created in App Android Studio

android Resources & R.java in hindi

हमारे Android App के “res” नाम की Directory में जितने भी Resources होते हैं, उन्‍हें अपने Android App की किसी भी Java File में Refer करने के लिए हमें इसी “R” Class को Use करना होता है और क्‍योंकि ये R नाम की Class केवल Static Resources को ही Represent करता है, इसलिए इस Class के सभी Members public static होते हैं।

Android R.java is an auto-generated file by aapt (Android Asset Packaging Tool) that contains resource IDs for all the resources of res/ directory.

If you create any component in the activity_main.xml file, id for the corresponding component is automatically created in this file. This id can be used in the activity source file to perform any action on the component.

Note: If you delete R.jar file, android creates it automatically.

Let’s see the android R.java file. It includes a lot of static nested classes such as menu, id, layout, attr, drawable, string etc.

  1. /* AUTO-GENERATED FILE.  DO NOT MODIFY. 
  2.  * 
  3.  * This class was automatically generated by the 
  4.  * aapt tool from the resource data it found.  It 
  5.  * should not be modified by hand. 
  6.  */  
  7.   
  8. package com.example.helloandroid;  
  9.   
  10. public final class R {  
  11.     public static final class attr {  
  12.     }  
  13.     public static final class drawable {  
  14.         public static final int ic_launcher=0x7f020000;  
  15.     }  
  16.     public static final class id {  
  17.         public static final int menu_settings=0x7f070000;  
  18.     }  
  19.     public static final class layout {  
  20.         public static final int activity_main=0x7f030000;  
  21.     }  
  22.     public static final class menu {  
  23.         public static final int activity_main=0x7f060000;  
  24.     }  
  25.     public static final class string {  
  26.         public static final int app_name=0x7f040000;  
  27.         public static final int hello_world=0x7f040001;  
  28.         public static final int menu_settings=0x7f040002;  
  29.     }  
  30.     public static final class style {  
  31.         /**  
  32.         Base application theme, dependent on API level. This theme is replaced 
  33.         by AppBaseTheme from res/values-vXX/styles.xml on newer devices. 
  34.      
  35.  
  36.             Theme customizations available in newer API levels can go in 
  37.             res/values-vXX/styles.xml, while customizations related to 
  38.             backward-compatibility can go here. 
  39.          
  40.  
  41.         Base application theme for API 11+. This theme completely replaces 
  42.         AppBaseTheme from res/values/styles.xml on API 11+ devices. 
  43.      
  44.  API 11 theme customizations can go here.  
  45.  
  46.         Base application theme for API 14+. This theme completely replaces 
  47.         AppBaseTheme from BOTH res/values/styles.xml and 
  48.         res/values-v11/styles.xml on API 14+ devices. 
  49.      
  50.  API 14 theme customizations can go here.  
  51.          */  
  52.         public static final int AppBaseTheme=0x7f050000;  
  53.         /**  Application theme.  
  54.  All customizations that are NOT specific to a particular API-level can go here.  
  55.          */  
  56.         public static final int AppTheme=0x7f050001;  
  57.     }  
  58. }  

source

android Uses-permission & uses-sdk in hindi

<uses-permission>

Note: In some cases, the permissions that you request through <uses-permission> can affect how your application is filtered by Google Play.

If you request a hardware-related permission — CAMERA, for example — Google Play assumes that your application requires the underlying hardware feature and filters the application from devices that do not offer it.

To control filtering, always explicitly declare hardware features in <uses-feature> elements, rather than relying on Google Play to “discover” the requirements in <uses-permission> elements. Then, if you want to disable filtering for a particular feature, you can add a android:required="false" attribute to the <uses-feature> declaration.

For a list of permissions that imply hardware features, see the documentation for the <uses-feature> element.syntax:

<uses-permission android:name="string"
        android:maxSdkVersion="integer" />

contained in:<manifest>description:Specifies a system permission that the user must grant in order for the app to operate correctly. Permissions are granted by the user when the application is installed (on devices running Android 5.1 and lower) or while the app is running (on devices running Android 6.0 and higher).

For more information on permissions, see the Permissions section in the introduction and the separate System Permissions API guide. A list of permissions defined by the base platform can be found at android.Manifest.permission.attributes:android:nameThe name of the permission. It can be a permission defined by the application with the <permission> element, a permission defined by another application, or one of the standard system permissions (such as "android.permission.CAMERA" or "android.permission.READ_CONTACTS"). As these examples show, a permission name typically includes the package name as a prefix.android:maxSdkVersionThe highest API level at which this permission should be granted to your app. Setting this attribute is useful if the permission your app requires is no longer needed beginning at a certain API level.

For example, beginning with Android 4.4 (API level 19), it’s no longer necessary for your app to request the WRITE_EXTERNAL_STORAGE permission when your app wants to write to its own application-specific directories on external storage (the directories provided by getExternalFilesDir()). However, the permission is required for API level 18 and lower. So you can declare that this permission is needed only up to API level 18 with a declaration such as this:

<uses-permission
     android:name="android.permission.WRITE_EXTERNAL_STORAGE"
     android:maxSdkVersion="18" />

This way, beginning with API level 19, the system will no longer grant your app the WRITE_EXTERNAL_STORAGE permission.

This attribute was added in API level 19.introduced in:API Level 1see also:

Gradle in hindi

Gradle-based build supportदरअसल Gradle किसी सॉफ्टवेयर डेवलपमेंट IDE में इस्तेमाल किया जाने वाला एक ऑटोमेशन टूल होता है जो सॉफ्टवेयर डेवलपमेंट प्रोसेस पर नियंत्रण करता है . Gradle की मदत से एंड्राइड स्टूडियो में ऍप बनाने में ज्यादा प्रोब्लेम्स नहीं आते है और छोटी से छोटी मिस्टेक भी हममे तुरंत पता लग जाती है 

Gradle-based build support दरअसल Gradle किसी सॉफ्टवेयर डेवलपमेंट IDE में इस्तेमाल किया जाने वाला एक ऑटोमेशन टूल होता है जो सॉफ्टवेयर डेवलपमेंट प्रोसेस पर नियंत्रण करता है . Gradle की मदत से एंड्राइड स्टूडियो में ऍप बनाने में ज्यादा प्रोब्लेम्स नहीं आते है और छोटी से छोटी मिस्टेक भी हममे तुरंत पता लग जाती है . एंड्राइड स्टूडियो में Gradle tool दिया हुआ है और यह पूरा IDE ऍप डेवलपमेंट से लेकर ऍप पब्लिशिंग तक Gradle पर काम करता है . Support for building Android Wear apps जी हाँ दोस्तों आप एंड्राइड स्टूडियो में स्मार्ट वॉचेस के लिए भी ऍप्स बना सकते है क्योंकि इसमें दिया गया है Android Wear apps का भी फीचर जिसमे आप स्मार्टवॉचेस के लिए भी ऍप्स बना सकते है . स्मार्टवॉचेस के लिए ऍप्स आप उसी तरीके से बना सकते है जैसे स्मार्टफ़ोन्स के बनाते है बस यहाँ पर स्क्रीन साइज अलग होती है बाकि सब चीजे वैसी ही रहेगी .

Read more at: https://techyatri.com/android-studio-kya-hai/

Manifest.xml in hindi

Introduction to AndroidManifest.xml File

AndroidManifest.xml  file  में आपके package की information होती है। आप अपनी application में जितने भी components यूज़ करते है उन सब की information AndroidManifest.xml file में होती है। जैसे सेर्वलेट्स में deployment descriptors होते है।

उसी प्रकार AndroidManifest.xml file भी आपकी application के लिए deployment descriptors की तरह होती है। ये आपकी application को कंट्रोल करती है। AndroidManifest.xml  file को देखकर आप बता सकते है की application में कितने और कौन कौन से components यूज़ हुए है।
जैसा की आप जानते है की हर android application में कम से कम एक Activity, Service, Broadcast receiver या Content Provider अवश्य होता है। जो की ये सभी components tasks को perform  करने के लिए Intent create करते है या intent filters के द्वारा खुद को intents के लिए register करते है। Intent और intent filters  2 अलग अलग element है जिन्हे AndroidManifest.xml file जोड़ती हैhttps://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-5239991314032243&output=html&h=280&slotname=4443653915&adk=2821391643&adf=2744942177&pi=t.ma~as.4443653915&w=725&fwrn=4&fwrnh=100&lmt=1649817694&rafmt=1&psa=0&format=725×280&url=https%3A%2F%2Fjavahindi.com%2F2021%2F05%2F18%2Fandroidmanifest-xml-file-in-hindi%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiMi4wLjAiLCJ4ODYiLCIiLCIxMDAuMC40ODk2Ljc1IixbXSxudWxsLG51bGwsIjY0IixbWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDAuMC40ODk2Ljc1Il0sWyJHb29nbGUgQ2hyb21lIiwiMTAwLjAuNDg5Ni43NSJdXSxmYWxzZV0.&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbSIsInN0YXRlIjoyMiwiaGFzUmVkZW1wdGlvblJlY29yZCI6dHJ1ZX1d&dt=1649817693783&bpp=12&bdt=2248&idt=1170&shv=r20220406&mjsv=m202204040101&ptt=9&saldr=aa&abxe=1&prev_fmts=0x0%2C725x280&nras=1&correlator=3534636769597&frm=20&pv=1&ga_vid=1058618757.1649817694&ga_sid=1649817695&ga_hid=1052628787&ga_fc=1&u_tz=-420&u_his=1&u_h=768&u_w=1366&u_ah=738&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=165&ady=1795&biw=1349&bih=635&scr_x=0&scr_y=0&eid=44759875%2C44759926%2C44759842%2C44761043%2C21067496&oid=2&pvsid=2071739278211674&pem=880&tmod=1858317599&uas=0&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C738%2C1366%2C635&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=3&uci=a!3&btvi=2&fsb=1&xpc=1GKXtQnNqY&p=https%3A//javahindi.com&dtd=1192

androidManifest.xml file in hindi

किसी भी application के components को आपकी application के protected part को access करने से पहले permission required होती है। ये permission AndroidManifest.xml file में declare होती है। Permission डिक्लेअर करने के लिए <uses-permission> tag यूज़ किया जाता है।
Application क्रिएट करते समय आप कोनसा android API यूज़ करते है ये आप AndroidManifest.xml file में डिक्लेअर करते है।

Elements of AndroidManifest.xml File

AndroidManifest.xml file कुछ elements से मिलकर बनी होती है।

<manifest> 

<manifest> एलिमेंट AndroidManifest.xml file का root element होता है। इसमें package attribute होता है जो activity क्लास के package name को describe करता है।

<application>   

<application> एलिमेंट <manifest> एलिमेंट का sub-element होता है। इस एलिमेंट के कई sub elements होते है। इस attribute में commonly icon, label और theme attributes यूज़ किये जाते है। आइये इनके बारे में कुछ जान लेते है।https://googleads.g.doubleclick.net/pagead/ads?client=ca-pub-5239991314032243&output=html&h=280&slotname=4443653915&adk=2821391643&adf=1323878283&pi=t.ma~as.4443653915&w=725&fwrn=4&fwrnh=100&lmt=1649817699&rafmt=1&psa=0&format=725×280&url=https%3A%2F%2Fjavahindi.com%2F2021%2F05%2F18%2Fandroidmanifest-xml-file-in-hindi%2F&fwr=0&fwrattr=true&rpe=1&resp_fmts=3&wgl=1&uach=WyJXaW5kb3dzIiwiMi4wLjAiLCJ4ODYiLCIiLCIxMDAuMC40ODk2Ljc1IixbXSxudWxsLG51bGwsIjY0IixbWyIgTm90IEE7QnJhbmQiLCI5OS4wLjAuMCJdLFsiQ2hyb21pdW0iLCIxMDAuMC40ODk2Ljc1Il0sWyJHb29nbGUgQ2hyb21lIiwiMTAwLjAuNDg5Ni43NSJdXSxmYWxzZV0.&tt_state=W3siaXNzdWVyT3JpZ2luIjoiaHR0cHM6Ly9wYWdlYWQyLmdvb2dsZXN5bmRpY2F0aW9uLmNvbSIsInN0YXRlIjoyOSwiaGFzUmVkZW1wdGlvblJlY29yZCI6dHJ1ZX1d&dt=1649817693813&bpp=4&bdt=2279&idt=1207&shv=r20220406&mjsv=m202204040101&ptt=9&saldr=aa&abxe=1&cookie=ID%3Dd13468a9c3377232-22ab5570eed100d8%3AT%3D1649840168%3ART%3D1649840168%3AS%3DALNI_MatDI3dIupxtx8kE8OPE81lZKDhRA&prev_fmts=0x0%2C725x280%2C725x280%2C195x240%2C195x240%2C1349x635&nras=4&correlator=3534636769597&frm=20&pv=1&ga_vid=1058618757.1649817694&ga_sid=1649817695&ga_hid=1052628787&ga_fc=1&u_tz=-420&u_his=1&u_h=768&u_w=1366&u_ah=738&u_aw=1366&u_cd=24&u_sd=1&dmc=4&adx=165&ady=2829&biw=1349&bih=635&scr_x=0&scr_y=600&eid=44759875%2C44759926%2C44759842%2C44761043%2C21067496&oid=2&psts=AGkb-H_U-wx9PJinJnWGNqkyOd3r1u_M_FaN4qSpcwovjVNgRHmJ9Fn9kRqErsXWvDEKpUMd-voJuutPEv-M78NfDw%2CAGkb-H-orFSWXZ_InSTJ1IbdrgEcu7smkk1nBCIgwCWz2I1vqZ5oqV0EzeEjWQTKm1B0TXCiPfpV8CU_xBLlBncXmA%2CAGkb-H9WV59cOaVIsAfT-Sbu-Y2N4KeXvAlFwlvGCSuXxf8ntmpuvdOa0J4jM6gUdr6BUAzErP0Co8BNOR6VLdo&pvsid=2071739278211674&pem=880&tmod=1858317599&uas=3&nvt=1&ref=https%3A%2F%2Fwww.google.com%2F&eae=0&fc=1920&brdim=0%2C0%2C0%2C0%2C1366%2C0%2C1366%2C738%2C1366%2C635&vis=1&rsz=%7C%7CeEbr%7C&abl=CS&pfx=0&fu=128&bc=31&ifi=4&uci=a!4&btvi=5&fsb=1&xpc=SKWhL7NXzd&p=https%3A//javahindi.com&dtd=5940

android:icon  – ये आपकी एप्लीकेशन के icon को represent करता है।
android:label  – ये आपकी application के label को represent करता है।
android:theme  – ये आपकी एप्लीकेशन की theme को represent करता है।

<activity> 

<activity> एलिमेंट <application> element का sub-element होता है। ये एक activity को दर्शाता है। इस एलिमेंट के 2 प्रमुख attributes होते है।

android:name – ये activity class के नाम को represent करता है।

android:label  – ये एक label होता है जो स्क्रीन पर डिस्प्ले होता है।

<intent-filter>

<intent-filter> एलिमेंट <activity> एलिमेंट का sub-element होता है। इसके तीन प्रमुख sub-elements होते है।

<action> – intent-filter किस प्रकार के action के intent को respond करेगा ये इसमें डिफाइन किया जाता है।

<data> – target component का URI इस एलिमेंट में डिफाइन किया जाता है।

<category> – ये activity की category को डिफाइन करता है।

reference-https://www.javatpoint.com/AndroidManifest-xml-file-in-

Android API levels (versions & version names) in hindi

एंड्राइड वर्जन क्या है? (What is Android Version in Hindi)
दोस्तों, आप एंड्रॉइड लॉलीपॉप (Android Lollipop), एंड्रॉइड किटकैट (Android KitKat), एंड्रॉएड नौगट (Android Nougat) इत्यादि जैसे नाम अक्सर सुनते होंगे। यदि आप नहीं जानते कि यह क्या है? तो मैं आपको बताता हूं कि ये सभी एंड्रॉइड के अलग-अलग संस्करण (Version) होते हैं। जो नई सुविधाओं (New Features) और सुधारों (Bug Fixes) के साथ अलग-अलग समय पर लॉन्च किया जाता है। सबसे पहले, मैं आपको बताउंगा कि संस्करण क्या होता है? संस्करण जिसे हम अंग्रेजी में वर्शन (Version) बोलते हैं, इसका मतलब है कि जब हम शुरुआत में कोई उत्पाद बनाते हैं, तो हम इसे संस्करण 1.0 जैसे नाम से लॉन्च करते हैं, लेकिन समय के साथ, जब हम उस उत्पाद में कोई नई सुविधा जोड़ते हैं या पुरानी त्रुटियों को हटाकर उत्पाद को बेहतर बनाते है, फिर हम उस उत्पाद को एक नई संस्करण के रूप में लॉन्च करते हैं, यानी, उत्पाद समान है, केवल कुछ नई विशेषताएं जोड़ें जाते है। और पुरानी समस्याएं जिसे हम बग (Bug) कहते है को ठीक किया जाता हैं, इसी तरह, एंड्रॉइड में नई सुविधाएं शामिल होती रहती हैं, और पहले से बेहतर एक नया संस्करण लॉन्च किया जाता है, वर्तमान में, एंड्रॉइड 8.1 ओरेओ (Android 8.1 Oreo) संस्करण 21 अगस्त, 2017 को लॉन्च किया गया था।

एंड्रॉइड के कई संस्करण आज आ गए हैं, वास्तव में, इसे एपीआई लेवल (API Level) भी कहा जाता है। एंड्रॉइड के नए संस्करण में कई नई विशेषताएं होती हैं, और इसके यूजर इंटरफेस (User Interface) में काफी सुधार किया गया होता है। एंड्रॉइड (Android) समय के साथ विकसित हो रहा है और नई सुविधाओं को शामिल किया जा रहा है। आज का एंड्रॉइड, लगभग हर वह काम कर सकता है जो एक कंप्यूटर सिस्टम (Computer System) कर सकता है, क्योंकि एंड्रॉइड ओएस (Android OS) को लगातार विकसित किया जा रहा है।

Google लगातार एंड्रॉइड ओएस के डेवलपमेंट (Android OS Development) पर काम कर रहा है। Google ने हर 6 महीने में एंड्रॉइड का नया संस्करण लॉन्च किया है, लेकिन अब हर साल एक नया संस्करण लॉन्च किया जा रहा है। Google एंड्रॉइड के संस्करण का नाम मिठाई या डेसर्ट पर रखता है और अल्फाबेटिकल ऑर्डर (Alphabetical Order) में अपने नये संस्करण (New version) का नाम रखता है। आइए इन सभी संस्करणों को एक-एक करके जाते है।

Android 1.0 – Alpha
Android 1.1 – Beta
Android 1.5 – Cupcake
Android 1.6 – Donut
Android 2.1 – Eclair
Android 2.2 – Froyo
Android 2.3 – Gingerbread
Android 3.2 – Honeycomb
Android 4.0 – Ice Cream Sandwich
Android 4.1 – Jelly Bean
Android 4.4 – KitKat
Android 5.0 – Lollipop
Android 6.0 – Marshmallow
Android 7.0 – Nougat
Android 8.0 – Oreo
Android 9.0 – Pie

UI Components – Views & notifications, Components for communication -Intents & Intent Filters

Android Notifications 

Notifications आपके device में top पर battery और signal icons के पास show होते है। आपने देखा होगा जैसे ही आपके device पर कोई mail या text message आता है तो top पर एक message icon शो होता है। ये messages notifications कहलाते है।

जब भी कोई notification आता है तो सबसे पहले उसका icon show होता है। जैसे की कोई mail आया तो Gmail का icon शो होगा। इसके बाद यदि यूज़र उस notification के बारे में detail जानना चाहता है तो वो notification drawer को open करता है।

ज्यादातर devices में notification drawer जब यूज़र top से bottom की तरफ swipe करता है तो open हो जाता है। Notification drawer को यूज़र कभी भी देख सकता है। इसमें कुछ दूसरी settings भी रहती है जैसे की WiFi, Bluetooth, screen brightness आदि होती है

आप चाहे तो notification के माध्यम से कोई action भी ले सकते है। जैसे की जब यूज़र notification पर click करे तो आपकी application open हो जाये। जँहा यूज़र दूसरे actions ले सकता है।

Contents of Android Notification 

  • Icon – ये एक छोटा सा icon होता है जो notification से related एप्लीकेशन को represent करता है
  • Title  – ये notification का title होता है जो की notification का purpose show करता है।
  • Detail text – ये detailed text message होता है।

Intents & Intent Filters

Android Intent एक ऐसा संदेश है जो गतिविधि broadcast रिसीवर, सामग्री providers, services आदि जैसे components के बीच पारित किया जाता है इसका उपयोग आम तौर पर गतिविधि, broadcast रिसीवर इत्यादि को प्रारंभ करने के लिए startActivity () method के साथ किया जाता है।

Intents एक asynchronous संदेश हैं जो एप्लिकेशन components को अन्य एंड्रॉयड components से कार्यक्षमता का अनुरोध करने की अनुमति देते हैं Intents आपको समान application से components के साथ-साथ अन्य application द्वारा योगदान components के साथ इंटरैक्ट करने की अनुमति देते हैं उदाहरण के लिए, एक activity एक तस्वीर लेने के लिए एक बाहरी activity शुरू कर सकती है।

Intents एंड्रॉइड content और Intent प्रकार की वस्तुओं हैं आपका कोड उन उपकरणों को परिभाषित कर सकता है जिसे आप target कर रहे हो उदाहरण के लिए, startActivity() विधि के माध्यम से आप यह परिभाषित कर सकते हो कि एक गतिविधि शुरू करने के लिए intent का उपयोग किया जाना चाहिए।

 

Android में अन्य application components का पुन: उपयोग टास्क के रूप में जाना जाता है टास्क प्राप्त करने के लिए एक application अन्य एंड्रॉइड उपकरणों तक पहुंच सकता है उदाहरण के लिए, आप application के एक component से, आप एंड्रॉइड सिस्टम में एक और component को ट्रिगर कर सकते हो , जो तस्वीरों को प्रबंधित करता है, भले ही यह component आपके आवेदन का हिस्सा न हो।

Android Intents Types

  • Implicit Intent
  • Explicit Intent

Implicit Intent

Implicit Intent component को निर्दिष्ट नहीं करता है ये Intent लागू होने वाले सिस्टम द्वारा प्रदान किए गए उपलब्ध components की जानकारी प्रदान करता है उदाहरण के लिए, यदि आप यूजर को map पर एक स्थान दिखाना चाहते हैं, तो आप किसी अन्य capable ऐप को नक्शे पर एक निर्दिष्ट स्थान दिखाने का अनुरोध करने के लिए एक implicit intent का उपयोग कर सकते हो।

Explicit Intent

Explicit Intent component को निर्दिष्ट करता है ऐसे मामले में, ये intent को लागू करने के लिए बाहरी वर्ग प्रदान करता है उदाहरण के लिए, आप यूजर एक्शन के जवाब में अपने ऐप के अंदर एक नई activity शुरू कर सकते हैं या पृष्ठभूमि में फ़ाइल डाउनलोड करने के लिए सेवा शुरू कर सकते हो।

source link 1

source link 1