What is components in Android ?
Android components are the essential building blocks of an Android application.
These components are loosly coupled from the android application.
All components are define in manifest file. Because manifest file is resposible to create object of android components and manager their life cycle.
There are following Android components:
Some other components :
View Group in Android
ViewGroup is an invisible container where all Views are orgnaised. It is a child class of View.
LinearLayout : It is used to orgnaised views in two direction horizontal and vertical.
RelativeLayout : It is used to orgnaised views in any direction.
FrameLayout : It is used to hold single view.
TableLayout : It is used to orgnaised views in Table format.
TableRow : It is used to orgnaised views in Horizontal. It is a part of TableLayout.
ListView : It is used to orgnaised views in List format.
GridView : It is used to orgnaised views in Grid format.
RecyclerView : It is a replacement of ListView and GridView. It is a material design view.
CardView : It is also a material design view.
WebView : It is used to support html,css type of code.
View in Android
View is a base class of all type of View or ViewGroup.
TextView : It is used to represent a text like JLabel in Java.
ImageView : It is used to hold image.
Button : It is used to perform action.
EditText : It is used to get infromation from user.
Space : It is used to provide a space.
View : It is used to draw a line.
Spinner : It is used as a combobox or dropdown box.
CheckBox : It is used to single or multiple or null selection.
RadioButton : It is used to single selection.
AutoCompleteTextView : It is used to provide suggestion when you search something.
MultiAutoCompleteTextView : It is used to provide multiple suggestion with delimeter. (done)
ScrollView : It is used to make vertical scrollable.
HorizontalScrollView : It is used to make Horizontal scrollable.
ImageButton : It is used to hold image as a button.
RatingBar : It is used to provide rating.
SeekBar : It is used to seeking the position like video,brightness,audio etc.
VideoView : It is used to play a video.
TimePicker : It is used to select Time.
TimePickerDialog : It is used to select time as a dialog.
DatePicker : It is used to select date.
DatePickerDialog : It is used to select Date as a Dialog.
SearchView : It is used to search a content in list or Recyclerview.
Switch : Switch is a two-state user interface element that is used to display ON (Checked) or OFF (Unchecked) states as a button with thumb slider.
ToggleButton : Toggle Button is a user interface control that is used to display ON (Checked) or OFF (Unchecked) states as a button with a light indicator.
Project Structure in Android :
app :
manifest : It is used to hold android components,permission,launcher application information etc.
java : It is used to hold business logic like perform validation,getting values from user,storing data into database etc.
asset : It is used to contain external file like JSON,XML,Font,CSV,Html,Css,Java Script,Jquery etc.
res : It is used to hold android resources file like image,audio,icons,colors,text etc.
drawable : It is used to hold image and custom shape or design.
layout : It is used to hold all screen or layout.
anim : It is used to hold animation file.
raw : It is used to hold music or audio files.
menu : It is used to hold menu files.
mipmap : It is used to hold launcher icon or application icon.
values : it is used to store color,text,group of text,size,theme etc.
strings.xml : It used to hold text or array information.
dimens.xml : It is used to hold dimens information.
colors.xml : It is used to hold color information.
theme.xml : It is used to hold your default or custom Theme.
How to measure a size in Android ?
In Android use all the below thing to measure the size of view like:
match_parent : it is use to resize according to parent.
wrap_content : it is used to resize according text.
dp or dip : dp stand for Density Independent Pixel or Density Pixel.
sp : sp stand for Scale Independent Pixel or Scale Pixel.
dpi : dpi stand for Dot Per Inches.
px : px stand for Pixel.
in : in stand for Inches.
Different Screen Size: in Android :
mdpi 160 dpi hdpi 240 dpi xhdpi 320 dpi xxhdpi 480 dpi xxxhdpi 640 dpi
Convert DP to PIXEL Formula:
px=dp*(dpi/160);
Using this formula your dp convert into pixel at runtime by Android System.
For Example :<ImageView android:layout_width="60dp" android:layout_height="60dp" src="@drawable/myimage">
So in Different size of devices it automatically converted by using above formula like:
In MDPI : 60*160/160 = 60px; In HDPI : 60*240/160 = 90px; In XHDPI : 60*320/160 = 120px; In XXDPHI : 60*480/160 = 180px; In XXXDPHI : 60*640/160 = 240px;Note : dp is used for all views but sp for text size.
No comments:
Post a Comment