Specifications
Related Android Design Pattern:
- Factory(Bitmap)
- Adapter(ListView)
- Builder(AlertDialog).
Directory:
Screen Layout:
This folder includes Relative Layout
Table Layout
Linear Layout
List View
Swipe Views
.
-
To apply a layout, follows:
- copy the layout.xml to
res/layout
folder in your project. - Pick the activity java class then modify
setContentView(R.layout.your_layout_name)
.
- copy the layout.xml to
-
List View
(List item value stored in .xml file):- for basic list view:
copy all four files in the
basic
folder seperately to your android project or create a class extends ListActivity(import related class)
create an XML file for string resources
create an XML file for display each item (type: TextView)
create ArrayAdapter to get the string[]
- for basic list view:
copy all four files in the
-
List View
(List item value stored in .java file, for activity not extend Listactivity):create an XML fiel for displaying each list item
create an string array to store value
create an Adapter to connect list value and item layout
create listview and connect it to xml file
setAdapter(listview reference)
-
Be aware of layout_weight.
Staggered GridView(Etsy):
- Setting up(ADT):
- Customization/Modification:
- TextView aligned on the bottom of layout:
android:layout_gravity="bottom"
- TextView background transparent with color, for example:
android:background="#B3000000"
, for other opacity refer bottom Reference. - ImageView in XML set scale:
android:scaleType="fitXY"
, fitting xy for example.
- TextView aligned on the bottom of layout:
- Ways to set image displayed in app.
- The XML way to set image in a layout:
- Put image into res->drawable folder
- Set
android:id="@+id/id-name" & android:src"@drawable/your-file-name"
in ImageView component - findViewById() way to set image:
- Create an ImageView variable for xml imageview component (import android.widget.ImageView). (Set android:id="@+id/id-name")
variable = (ImageView) findViewById(R.id.id-name)
, link it.- use imageview variable method
setImageResource(R.drawable.your-file-name)
to get the image file.
=
Icon:
- copy icons image seperately to
drawable
folder underres
; - change
android:icon="@drawable/your_icon_name
inAndroidManifest.xml
;
=
Splash screen:
- for basic splash screen: copy all three files into different folders in your project or
- create a handler and also use its
Handler().postDelayed(new Runnable(), SPLASH_DISPLAY_LENGTH)
- Override
run()
method. - full screen: add
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
toAndroidManifest.xml
. - (Optional for splash screen) add
android:screenOrientation="portrait"android:theme="@android:style/Theme.Black.NoTitleBar"
, this will let the splash screen with a status bar and perform perfect sa far.
=
Alert Dialog:
- (Skip step) For the fluent UI and hold the main UI thread runs without clogging, we could set up a new worker thread to finish the job.
new a handler, new a runnable
and override therun()
method. new AlertDialog
inside the block and set the its builder for the specific activity.setTitle()
,setMessage()
,setCancelable(boolean)
,setNegativeButton("string",Override OnClickListenr() method)
.- call the
.create()
and.show()
method.
=
Navgation bar listening:
= onSaveInstanceState = onUserLeaveHint = ACTION_CLOSE_SYSTEM_DIALOGS = Framework PhoneWindowManager.java
Debug:
- Using logcat to debug:
- create
log
class then using its d method to pass the tag and message. - Using
toast
to test:Toast.makeText(context, message, duration).show();
, for the context arguement I would like to use this for current class.
=
Reference:
=
http://stackoverflow.com/questions/15852122/hex-transparency-in-colors
Hex Values Opacity |
---|
100% — FF |
95% — F2 |
90% — E6 |
85% — D9 |
80% — CC |
75% — BF |
70% — B3 |
65% — A6 |
60% — 99 |
55% — 8C |
50% — 80 |
45% — 73 |
40% — 66 |
35% — 59 |
30% — 4D |
25% — 40 |
20% — 33 |
15% — 26 |
10% — 1A |
5% — 0D |
0% — 00 |