[go: up one dir, main page]

0% found this document useful (0 votes)
33 views26 pages

Android Workshop

Uploaded by

pushpak84shinde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views26 pages

Android Workshop

Uploaded by

pushpak84shinde
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

What is Android

• It is modified version of Linux kernel & Other Open Source


Software
• It is primarily designed for touchscreen mobile devices
such as
smartphones and tablets.

About Android Open Source

High Success
Ratio Best Dev. Tools

Less Development Easy to


Cost Understand

Larger
Market Scale Community
Where Android Is?

Phone and Tablets Smart Watch

Cars Smart TV
Pre-Requirements to Learn Android
• Core Java

• Kotlin (optional)

• Java Collections Framework

• OOP’s

• XML (Tags, Attributes)

• MySQL (Basic Queries)


Android
Architectur The Libraries which directly available to developers

e written in Java

Many core Android system Devices which run 5.0 or higher, each app runs in its own
components and services, process and with its own instance ART. ART is written to
are built from native code run multiple virtual machines on low-memory devices by
that require native libraries executing DEX files,
written in C and C++.

provides standard interfaces that expose device


hardware capabilities.
When Framework API calls Android system loads
the library module for that hardware component.

It is Foundation of Android Platform,


Linux Kernel Allows android to take
Security features
Let’s Explore Android Studio
Layout
s • Constraint Layout (High Use)
• Constraints
• Chains
• Helper
• Linear Layout (High Use)
• Vertical
• Horizontal

• Frame Layout
• Table Layout

• Grid Layout (Legacy / Deprecated)

• Relative Layout (Legacy / Deprecated)


Android Widgets
• Text View, • RecyclerView
• EditText • ViewPager
• ImageView • CardView
• Button • NavigationDrawer
• Checkbox • BottomNavigation
• Radio button • Three Dot Menu
• FAB • Toolbar
• Switch • Fragments
• Spinner • AutoCompleteTextView
• Progress bar • Toast, SnackBar, Dialog
• Ratingbar • Bottom Sheet
• Horizontal ScrollView
• ScrollView
TextVie
w
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
android:textSize="32sp"
android:textColor="@color/black"
android:fontFamily="monospace"
android:textStyle="bold"
android:textAllCaps="true"
android:textDirection="rtl"
android:textFontWeight="900“ (Attrb use API 28 and
Higher) android:textScaleX="4"
android:tooltipText="Hello Students"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<EditText
EditTex android:id="@+id/id_input_text"
android:layout_width="match_parent"
t android:layout_height="wrap_content"
android:hint="Enter Something new different keyword"
android:layout_margin="30dp"
android:layout_gravity="center"
android:padding="16dp"
android:textColor="@color/purple_700"
android:textColorHint="@color/black"
android:textStyle="italic"
android:inputType="phone"
android:maxLength="10"
android:digits="0123456789"
android:drawableStart="@drawable/ic_android"
android:drawablePadding="12dp"
android:drawableEnd="@drawable/ic_android"
android:maxLines="2"
android:fontFamily="monospace"
android:typeface="monospace"
android:visibility="visible"
android:textSize="24sp"
android:enabled="true"
android:ellipsize="end"

android:rotationX="45"

android:rotationY="45"
android:alpha="0.5"
/>
ImageView

<ImageView
android:id="@+id/id_img_imgName"
android:layout_width="320dp"
android:layout_height="320dp"
android:layout_gravity="center"
android:adjustViewBounds="false"
android:alpha="0.5"
android:scaleType="fitXY"
android:src="@drawable/ic_android"
android:contentDescription="android
image" />
Button

<Button
android:id="@+id/id_button_buttonName"
android:layout_width="320dp"
android:layout_height="wrap_content"
android:text="Submit"
android:textAllCaps="false"
android:textColor="@color/white"
android:textSize="24sp"
android:textStyle="italic"
android:background="@drawable/button_back“
/>
Add Data-Binding
Data Binding is Nothing but binding data to xml view directly without finding of id of them

To Add DataBinding in Project add following code in build.gradle file

buildFeatures {
dataBinding true
}

• Add layout tag in xml file


• And initialized binding object in java file and access view
from binding object
CheckBox

<CheckBox
android:id="@+id/id_check_android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Android"
android:buttonTint="#0000ff"
android:checked="true" />

binding.idButtonSubmit.setOnClickListener(v -> {
courses.clear();
if(binding.idCheckAndroid.isChecked())
{
courses.add("Android");
}
}
Radio Button
<RadioGroup
android:id="@+id/id_radio_grp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="30dp"
android:layout_gravity="center"
android:orientation="horizontal">

<RadioButton
android:id="@+id/id_button_male"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:buttonTint="#0000ff"
android:checked="true"
/>
</ RadioGroup>

Listeners,

RadioButton.setOnCheckedChangeListener()
RadioGroup.
setOnCheckedChangeListener()
Spinner
<Spinner
android:id="@+id/id_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:entries="@array/course_list"
android:padding="30dp"
android:spinnerMode="dialog || dropdown“
/>

Spinner .
setOnItemSelectedListener()
CardView

<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_margin="30dp"
app:cardBackgroundColor="#e5e5e5"
app:cardCornerRadius="36sp"
app:cardElevation="8dp"
android:rotation="-45“
/>
Toolba
r
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/purple_500"
app:navigationIcon="@drawable/ic_arrow_toleft"
app:navigationContentDescription="@string/app_na
me" app:logo="@drawable/ic_android"
app:title="Title"
app:titleTextColor="@color/white"
app:subtitle="Sub Title"
app:subtitleTextColor="@color/white"
app:titleMarginStart="30dp"
app:menu="@menu/menu“ />
RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_recycler"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipToPadding="false"
app:layoutManager=".LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:itemCount="10"
tools:listitem="@layout/raw_layout" />

Create Adapter Custom class to bind all views


ViewPager-2

<androidx.viewpager2.widget.ViewPager2
android:id="@+id/id_viewPager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal | Verticle"
/>

Adapter

class ViewPagerAdapter extends


FragmentStateAdapter {
public ViewPagerAdapter(@NonNull FragmentActivity
fa) {super(fa); }

@NonNull @Override
public Fragment createFragment(int position) {
return new TestFragment(); }

@Override
public int getItemCount() { return 8; }
}
Navigation Drawer

Toolbar
-> DrawerLayout
-> NavigationView
-> Header
-> Menu

ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this,


binding.idDrawer,
binding.idToolbar,
R.string.open,R.string.close);
toggle.syncState();
Three Dot Menu

Add Custom Toolbar with menu attribute

setSupportActionBar(binding.idToolbar);

Override 2 Mothods

onCreateOptionMenu() getMenuInflater().inflate(R.menu.menu,menu);

onOptionsItemSelected (item) { item.id == R.id.menuId}


Bottom Navigation Menu
<com.google….BottomNavigationView
android:id="@+id/id_bottomNav"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:itemTextColor="#0000ff"
app:menu="@menu/menu"
app:elevation="8dp"
app:itemIconSize="36sp"
app:itemIconTint="#0000ff"
app:itemRippleColor="@color/black"
app:backgroundTint="#ddd“ />

Listeners : setOnItemSelectedListener()
Activity
- An activity is the entry point for interacting with
the user. It represents a single screen with a user
interface, You implement an activity as a subclass
of the Activity Class

- Lifecycle
- Activities overridden Methods
- Intent for
- New Activity
- Open Messaging App
- Open Gmail
- Open Phone App
- Open Camera
- Open Gallery
- StartActivityForResult
- Share Text

Restricted @ InnovationsHub Service Pvt Ltd www.innovationshub.com Contact@innovationsHub.com


Fragment
• Lifecycle

• Attach, Detach, Add, Remove, Replace

• What is Backstack?

• Add Fragment to Backstack

• Send Data to other Fragment

• Get Data From Other Fragment

Restricted @ InnovationsHub Service Pvt Ltd www.innovationshub.com Contact@innovationsHub.com


Lets Design Screen
Lets Design Screen

You might also like