Android Tutorial – Android UI Overview




All UI components in an Android application are manufactured utilizing View and ViewGroup objects. A View is an article that draws something on the screen that the client can collaborate with. A ViewGroup is an article that holds other View (and ViewGroup) objects with a specific end goal to characterize the design of the interface.

image (1)

 

Android gives a gathering of both View and ViewGroup subclasses that offer you regular info controls, (for example, catches and message fields) and different design models, (for example, a direct or relative format).

Android Screen UI Components

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
</LinearLayout>

Amid runtime, you stack the XML UI in the onCreate() occasion handler in your Activity class, utilizing the setContentView() technique for the Activity class:

@Override
    public void onCreate(Bundle savedInstanceState) {     
     super.onCreate(savedInstanceState);     
     setContentView(R.layout.main);
    }

LinearLayout

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    >
    <TextView  
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:text="@string/hello"
        />
</LinearLayout>

Views

Types of views:

    • TextView, ImageView, Button…
    • ListView, GridView
    • Recycler View
    • ViewPager

Here’s the layout component activity_album_list.xml that I had written.

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	tools:context=".AlbumListActivity">

	<android.support.v7.widget.Toolbar
		android:layout_width="match_parent"
		android:layout_height="wrap_content"
		android:layout_alignParentTop="true"
		android:is="@+id/toolbar"
		android:background="?attr/colorPrimary"
		style="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
		/>
	<android.support.v7.widget.RecyclerView
		android:id="@_id/album_list"
		android:layout_below="@id/toolbar"
		android:layout_width="match_parent"
		android:layout_height="match_parent" />
</RelativeLayout>

AlbumListActivity.java

public class AlbumListActivity extends ActionBarActivity {
	public static Object sHook;
	@InjectView(R.id.album_list)
	RecyclerView mAlbumList;

	@InjectView(R.id.toolbar)
	Toolbar mToolbar;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_album_list);

		ButterKnife.inject(this);
		mToolbar.inflateMenu(R.menu.menu_album_list);
		populate();
	}
	
	interface OnVHClickedListener {
		void onVHClicked(AlbumVH vh);
	}

	static class AlbumVH extends RecyclerView.ViewHolder implement…
		private final OnVHClickedListener mListener;
		@InjectView(R.id.album_art)
		ImageView albumArt;
		@InjectView(R.id.name)…

 


Partner Sites

VideoToGifs.com

EasyOnlineConverter.com

SqliteTutorials.com





Be the first to comment

Leave a Reply

Your email address will not be published.


*