Ma Unit3

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 13

User Interface Screen Elements

1. Navigation Bar
 Purpose: Provides a way to navigate between different
sections or screens of the app.
 Location: Typically at the top of the screen (top
navigation) or the bottom (bottom navigation).
 Elements:
o Title: Displays the current screen’s title.

o Icons/Buttons: For actions such as back, home,

search, or other navigational controls.


2. Toolbar/Action Bar
 Purpose: Provides contextual actions related to the
current screen.
 Location: Typically at the top of the screen.
 Elements:
o Action Items: Buttons or icons for actions like

search, settings, or sharing.


o Overflow Menu: For additional actions that don’t

fit in the toolbar.


3. Buttons
 Purpose: Triggers actions when tapped.
 Types:
o Primary Button: Main action button, usually

stands out with distinct styling.


o Secondary Button: Less prominent actions.

o Floating Action Button (FAB): Circular button

that floats above the UI, for primary actions.


 States: Default, pressed, disabled.
4. Forms and Input Fields
 Purpose: Collect user input.
 Types:
o Text Fields: For entering text.

o Password Fields: Masked text input.

o Text Areas: Multi-line text input.

o Date Pickers: For selecting dates.

o Check Boxes: For binary choices.

o Radio Buttons: For selecting one option from a set.

o Dropdown Menus: For selecting from multiple

options.
5. Modals and Dialogs
 Purpose: Display information or request input without
leaving the current context.
 Types:
o Alert Dialogs: For alerts and confirmations.

o Bottom Sheets: Slide up from the bottom,

providing additional actions or information.


o Full-Screen Modals: Take over the entire screen

for tasks that require focus.


6. Lists and Grids
 Purpose: Display collections of items.
 Types:
o List View: Vertically scrollable list of items.

o Grid View: Items arranged in a grid.

o Recycler View (Android): Optimized list for better

performance with large datasets.


7. Images and Icons
 Purpose: Enhance visual appeal and provide visual cues.
 Types:
o Icons: Simple graphics representing actions or

statuses.
o Images: Photos, illustrations, or any other visual

content.
8. Notifications and Snackbars
 Purpose: Provide feedback or updates to the user.
 Types:
o Notifications: System-level alerts that appear

outside the app.


o Snackbars: Brief messages that appear at the

bottom of the screen and disappear after a few


seconds.
9. Sliders and Pickers
 Purpose: Allow users to select values within a range.
 Types:
o Sliders: Horizontal bars that users can slide to

select a value.
o Pickers: Spinners or scrollable lists for selecting

values.
10. Search Bars
 Purpose: Allow users to search within the app.
 Elements:
o Input Field: For entering search queries.

o Search Icon: Icon to initiate the search.


Designing for Mobile UI
When designing mobile UI elements, keep the following
principles in mind:
1. Consistency: Use consistent styling and behavior for
similar elements.
2. Feedback: Provide immediate visual or haptic feedback
for user actions.
3. Accessibility: Ensure elements are accessible to all
users, including those with disabilities.
4. Clarity: Design with clear, concise text and intuitive
icons.
5. Performance: Optimize elements for smooth
performance, especially on lower-end devices.

Designing User Interface with Layouts


1. Understanding Layout Types
Linear Layout
 Description: Arranges elements in a single direction:
vertically or horizontally.
 Use Cases: Simple screens where elements need to be
displayed in a sequence, such as forms or lists.
 Example (Android XML):
<LinearLayout android: layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title" />
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content" android:hint="Enter
text" />
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Submit"
/>
</LinearLayout>

Relative Layout (Android) / Constraint Layout (iOS and


Android)
 Description: Positions elements relative to each other or
to the parent container. Constraint Layout is more powerful
and flexible.
 Use Cases: Complex screens where elements need
precise alignment relative to each other.
 Example (Android XML - Constraint Layout):
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<TextView android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Title"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<EditText android:id="@+id/editText"
android:layout_width="0dp"
android:layout_height="wrap_content" android:hint="Enter
text" app:layout_constraintTop_toBottomOf="@+id/title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<Button android:id="@+id/Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Submit"
app:layout_constraintTop_toBottomOf="@+id/Button"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout/>
Frame Layout
 Description: Designed to block out an area on the screen
to display a single item.
 Use Cases: Simple overlay elements like banners or a
single item view.
 Example (Android XML):
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/image" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Overlay
Text" android:layout_gravity="center" />
</FrameLayout>
Grid Layout
 Description: Arranges elements in a grid of rows and
columns.
 Use Cases: Displaying data in a grid format, such as
image galleries or product listings.
 Example (Android XML):
<GridLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:columnCount="2" android:rowCount="2">
<ImageView android:layout_width="0dp"
android:layout_height="0dp" android:layout_row="0"
android:layout_column="0" android:layout_gravity="fill"
android:src="@drawable/image1" />
<ImageView android:layout_width="0dp"
android:layout_height="0dp" android:layout_row="0"
android:layout_column="1" android:layout_gravity="fill"
android:src="@drawable/image2" />
<ImageView android:layout_width="0dp"
android:layout_height="0dp" android:layout_row="1"
android:layout_column="0" android:layout_gravity="fill"
android:src="@drawable/image3" />
<ImageView android:layout_width="0dp"
android:layout_height="0dp" android:layout_row="1"
android:layout_column="1" android:layout_gravity="fill"
android:src="@drawable/image4" />
</GridLayout>
2. Design Principles
Consistency
 Maintain a consistent design language throughout the
app to provide a cohesive experience.
 Use consistent colors, fonts, and element sizes.
Clarity and Simplicity
 Ensure the UI is easy to understand and use.
 Avoid clutter and provide only necessary elements to the
user.
Feedback
 Provide immediate feedback for user actions.
 Use animations, color changes, or messages to indicate
processing or errors.
Accessibility
 Design for all users, including those with disabilities.
 Use large touch targets, clear labels, and support for
screen readers.
Tools and Resources
Design Tools
 Figma: Collaborative interface design tool.
 Sketch: Design tool specifically for macOS.
 Adobe XD: Design and prototyping tool.
Development Tools
 Android Studio: Integrated development environment
(IDE) for Android.
 Xcode: IDE for iOS development.

Drawing and working with Animations


Setting Up Your Project
First, make sure you have an Android project set up in
Android Studio. If you don't have one, create a new project.
Drawing with Canvas
You can draw custom graphics using the Canvas class. To do
this, you'll need to extend the View class and override the
onDraw() method.
public class MyCustomView extends View
{
private Paint paint = new Paint();
public MyCustomView(Context context)
{
super(context);
paint.setColor(Color.RED); // Set your paint color
paint.setStrokeWidth(10f); // Set the stroke width
}
@Override protected void onDraw(Canvas canvas)
{
super.onDraw(canvas);
canvas.drawCircle(150, 150, 100, paint); // Draw a circle
}
}

Add this custom view to your layout:


<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.example.yourapp.MyCustomView
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Simple View Animations
You can animate views using the built-in animation
framework. For example, to move a view across the screen:
View view = findViewById(R.id.your_view);
ObjectAnimator animator = ObjectAnimator.ofFloat(view,
"translationX", 0f, 300f); animator.setDuration(1000);
animator.start();
Property Animations
Property animations allow more flexibility and power in
animations. You can animate almost any property of a view.
ObjectAnimator alphaAnimator =
ObjectAnimator.ofFloat(view, "alpha", 1f, 0f);
alphaAnimator.setDuration(1000);
alphaAnimator.start();

Apply this animation in your Java/Kotlin code:


Animation fadeOut = AnimationUtils.loadAnimation(this,
R.anim.fade_out);
view.startAnimation(fadeOut);

AnimatorSet for Complex Animations


Use AnimatorSet to play animations together or sequentially.
ObjectAnimator scaleX = ObjectAnimator.ofFloat(view,
"scaleX", 1f, 1.5f);
ObjectAnimator scaleY = ObjectAnimator.ofFloat(view,
"scaleY", 1f, 1.5f);
AnimatorSet animatorSet = new AnimatorSet();
animatorSet.playTogether(scaleX, scaleY);
animatorSet.setDuration(1000);
animatorSet.start();
Frame-by-Frame Animations
You can create frame-by-frame animations by defining a
series of drawable resources in an XML file.
<!-- res/drawable/frame_animation.xml -->
<animation-list
xmlns:android="http://schemas.android.com/apk/res/android"
android:oneshot="false">
<item android:drawable="@drawable/frame1"
android:duration="50" />
<item android:drawable="@drawable/frame2"
android:duration="50" />
<!-- More frames -->
</animation-list>
Start the animation in your code:
ImageView imageView = findViewById(R.id.image_view);
imageView.setBackgroundResource(R.drawable.frame_anima
tion);
AnimationDrawable frameAnimation = (AnimationDrawable)
imageView.getBackground();
frameAnimation.start();
ViewPropertyAnimator for Simple Animations
ViewPropertyAnimator provides a simple way to animate
properties of a view.
view.animate().alpha(0f).setDuration(1000);

Transition Framework
For animating between different UI states in activities and
fragments.
TransitionManager.beginDelayedTransition(viewGroup);
view.setVisibility(View.GONE);

You might also like