quartz/content/vault/byu/Widgets and Layouts used.md
2022-06-07 16:56:28 -06:00

67 lines
2.4 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#cs240
Layouts
http://developer.android.com/guide/topics/ui/declaring-layout.html
Child views have “layout_*” attributes that specify how the containing layout should arrange them (see layoutparams.png)
Universal layout attributes:
layout_width, layout_height
wrap_content, match_parent
specific values (e.g., 30dp)
LinearLayout
orientation
LinearLayout.LayoutParams:
https://developer.android.com/reference/android/widget/LinearLayout.LayoutParams.html
RelativeLayout
RelativeLayout.LayoutParams:
https://developer.android.com/reference/android/widget/RelativeLayout.LayoutParams.html
GridLayout
rowCount, columnCount
GridLayout.LayoutParams:
https://developer.android.com/reference/android/widget/GridLayout.LayoutParams.html
FrameLayout
Used as placeholder for dynamically created fragments
FrameLayout.LayoutParams:
https://developer.android.com/reference/android/widget/FrameLayout.LayoutParams.html
Layout Exercises
How would you create the following layouts (widgets and layouts)? [Widgets used are listed below]
Login Fragment
Map Fragment
Main Activity
Person Activity
Map Activity
Widgets / Atrributes / Events
http://developer.android.com/guide/topics/ui/controls.html
TextView (text labels)
text, textAppearance
.setClickable(boolean) make clickable
.setOnClickListener(View.OnClickListener)
EditText (text fields)
inputType, ems
.addTextChangedListener(TextWatcher)
Space (blank space)
set layout_width and layout_height to specific values (e.g., 30dp)
Button
text
.setOnClickListener(View.OnClickListener)
ImageView (display image)
.setClickable(boolean) make clickable
.setImageDrawable(IconDrawable) set icon to display
.setOnClickListener(View.OnClickListener)
Switch (on/off)
.setChecked(boolean) set check state
.setOnCheckedChangeListener(CompoundButton.OnCheckedChangeListener)
Spinner (dropdown list)
.setAdapter(ArrayAdapter) specify list values
.setSelection(int) specify selected item
onItemSelectedListener(AdapterView.OnItemSelectedListener)
SearchView
.setFocusable(boolean) accept key focus
.setIconified(boolean) make always visible
.requestFocusFromTouch() request focus when touched
.setOnQueryTextListener(SearchView.OnQueryTextListener)
ScrollView
Wrap around any view to make it scrollable
RecyclerView
Dynamic lists of items
* ListView / ExpandableListView