pel programming {BBA (CA): Som. VI} 2.29
° Activity, Intent and Layout
ndroidiide"@rid/txtPassword”
indroid:inputTypes"textPassword"/>
ptableRow>
‘rableROW?
qrextview />
checkBox. android: id="@+4d/chkRemenberPassword”
jndroid: 1ayout_width="#411_parent™
android: Layout_height="wrap_content”
android: text="RememberPassword"/>
«/TableRow>
cTableRow>
res >
I layout > activity_main.xml and add the below
code to that file. Below is the code for the activity_main.xml file.
Gaeik
Kamil Khan
Fig. 2.23: Constraint LayoutAndroid Programming [BBA (CA) : Sem. VI] 234 ‘Activity Intent and Layou,
FrameLayout
. The FrameLayout layout is a placeholder on screen that you can use to display a
single view. Views that you add to a FrameLayout are always anchored to the top left
of the layout.
ean
+ Consider the following content in main.xml:
<2xml version="1.0" encoding="utf-8"?>
canageview
android: “@mipmap/butterfly"
android: layout_width="
android: Layout_height=
e/FrameLayout>
rap_content"
wrap_content"/>
«/relativeLayout>
Here, you have a FrameLayout within a RelativeLa ithi:
; yout. Within the FrameLayout, you
embed an ImageView. The Ulis shown in Fig. 2.25. you
Fig, 2.25: FrameLayout within RelativeLayout
If you add another view (such as a Button view) within the FrameLayout, the view
overlaps the previous view (See Fig. 3.26)
“wrap_content"
ayout_height='
android:text="Hello, Android!”
android: layout_alignParentTop="true"
"wrap_content™ivity, Intent
periraid Programming [BBA (CA) : Sem. VO} 2.36 Activity, Intent and Lay,
leyout_glignParentStart="true"/>
yout
rap_content"
slayout_width=
‘wrep_content”
:leyout_elignStert="@+id/1b1Comments”
: layout_below="@+id/1b1Comments"
layout_centerHorizontal="true">
layout,
android: src="@nipmap/butterfly”
android: leyout_width="wrap_content”
android: leyout_height="wrap_content"/>
layout_width="124dp"
android: leyout_height="wrap_content”
android:text="PrintPictur
|
|
|
|
A
Fi
Fig. 2.26: Overlappin,
, ig Of FrameLay
EEX] scrotview oat
4 i
Space than tj
Linearlayout ild view or Views; he physical display. The
+ In Scrottyi, Toup, which normally is #
lew a pri +
ld view, group that contains one otherniold Programming [BBA (CA): Sem, vi
a
2.37
Activity, Intent and Layout
Scroll up to see
bottorn view.
is visible,
i viible it you
roll ony more,
Fig. 2.27: absoluteLayout in Android
+ The following main.xml content she
which is contains some Button and E
+ If you load the preceding co
what's shown in Fig. 2.28.
de on the Android emulator, you see something like
Fig. ei
‘ig. 2.28: AbsoluteLayout Screen-
ramming [BBA (CA) : Sem. VI
anaroid Pro en) Activity, Intent and Layout
gecause the EditText automatically gets the focus, it fills up the entire activity (as the
height was set to 600dp). To prevent it from getting the foeus, add the following two
polded attributes to the, *
qineartayout> element:
cLinearLayout
android: layout_width="#i1l_parent”
android: 1ayout_heigh
android:orientation="vertical"
android: focusable="true"
android: focusableTnTouchMode="true">
Now you are able to view the buttons and scroll through the list of views
(Gee Fig. 2.29).
‘wrap_content"
Fig. 2.29: ScrollView with LinearLayout
ht want EditText to automatically get the focus, but you do not
yyboard) to appear automatically (which happens on a
keyboard from appearing, add the following bolded
the AndroidManifest.xml file:
* Sometimes you mig!
want the soft input panel (Ke!
Teal device), To prevent the
attribute to the element in
cactivity
android: 1abel="@string/app_name”
-LayoutsActivity"
android: name='Android Programming [BBA (CA) : Sem. VI] 2.40
Activity, Intent and Layou,
jputMode="stateHidden™>
‘android.intent.action.MAIN" />
ory android:nane="android. intent.category.LAUNCHER"/>
at-Filter>
Eure ts
Y
Y
\
Y
\
The Android activity life cycle defines the states or events that an activity goes
through from its creation until its end, The activity monitors and reacts to these
events by executing methods that override the activity class methods for each
event.
The intent generally consists of activities to be done, the parameter over which
this activity is to be performed and the application to perform this action.
Intents can be either explicit or implicit. An explicit intent calls a specific service
or activity explicitly; whereas an implicit intent just gives the definition of the
required service.
An Intent object is a bundle of information which is used by the component that
Teceives the intent as well as information used by the Android system. An intent
filter is an expression in an app's manifest file that specifies the type of intents
that the component would like to receive.
Various methods of Activity life cycle includes onCreate(), onStart(), onResume(),
onPause(), onStop(), onDestroy() and onRestart(.
Intents are asynchronous messages which allow application
components to
Feduest functionality from other Android components,
automatically by Android, whi
element.