Saving your ample hours of designing and developing the Android UI being our goal, We now present to you the news feed app screen with the detailed process.
Step 01 :
Create a new project in Android Studio from the File ⇒ New Project. As it prompts you to select the default activity, select Empty Activity and proceed.
Name your project as per your convenience and click finish.
Download this res.zip and add them to your project res folder. This file contains a few drawable images and font folder required for this app.
Now that we are done with the images, moving on to changing the text font. For this, we would need to add a custom font in our directory and asset folder as well. find custom fonts folder and asset folder and paste it under the java. Here is a reference image for custom fonts folder
Watch this video tutorial for step 1 here.
Step 02 :
Go to the build Gradle and do the needful changes as follows.
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' implementation 'com.android.support:design:29.0.2' implementation 'androidx.cardview:cardview:1.0.0' }
Open colors.xml located under res ⇒ values and add the below color values.
<?xml version="1.0" encoding="utf-8"?> <resources> <color name="colorPrimary">#1976D2</color> <color name="colorPrimaryDark">#1565C0</color> <color name="colorAccent">#FDD835</color> <color name="grey_medium">#666666</color> <color name="textcolor">#131314</color> <color name="overlay_dark_60">#99000000</color> </resources>
Open styles.xml located under res ⇒ values and add the below values.
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> <item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorAccent">@color/colorAccent</item> <item name="windowNoTitle">true</item> <item name="android:windowFullscreen">true</item> </style> </resources>
Create dimen.xml under res ⇒ values and add the below values.
<resources> <dimen name="spacing_large">15dp</dimen> <dimen name="spacing_middle">10dp</dimen> </resources>
Step 03 :
Now is the time for making the XML file. For this, Open activity_main.xml and paste the following code.
<?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:orientation="vertical" android:layout_height="match_parent" tools:context=".MainActivity"> <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/map" android:scaleType="centerCrop"/> <include layout="@layout/toolbar_nearby"/> </FrameLayout> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginTop="219dp" android:src="@drawable/icon_map"/> <customfonts.TextView_Lato_Regular android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="13.4sp" android:textColor="#fefeff" android:layout_above="@+id/cardview" android:layout_marginRight="15.4dp" android:layout_marginLeft="15.4dp" android:letterSpacing="0.03" android:layout_marginBottom="30dp" android:lineSpacingExtra="2.6sp" tools:text="Popular places" /> <HorizontalScrollView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/cardview" android:background="@drawable/bg_gradient_hard" android:layout_alignParentBottom="true" android:scrollbars="none"> <LinearLayout android:layout_width="wrap_content" android:layout_marginBottom="48dp" android:layout_height="wrap_content"> <androidx.cardview.widget.CardView android:layout_width="150dp" android:layout_marginTop="30dp" android:layout_height="214.2dp" android:layout_marginRight="10dp" android:layout_marginLeft="15.4dp" app:cardElevation="0dp" android:elevation="0dp" app:cardCornerRadius="9dp" android:layout_marginEnd="10dp" android:layout_marginStart="15.4dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:scaleType="centerCrop" android:src="@drawable/nearby_imgone"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16.2sp" android:textColor="#131314" android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:lineSpacingExtra="2.8sp" android:text="Surfing" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="11.5sp" android:textColor="#8f8f8f" android:layout_gravity="center" android:layout_marginLeft="10dp" android:lineSpacingExtra="1.5sp" android:text="15 min" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="11.5sp" android:layout_marginRight="10dp" android:textColor="#8f8f8f" android:layout_gravity="center" android:lineSpacingExtra="1.5sp" android:gravity="end" android:text="37 m" /> </LinearLayout> <RatingBar android:layout_marginLeft="10dp" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_marginTop="10dp" android:layout_height="wrap_content" android:numStars="5" android:rating="4" android:layout_marginStart="10dp" /> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:layout_width="150dp" android:layout_marginTop="30dp" android:layout_height="214.2dp" android:layout_marginRight="10dp" android:layout_marginLeft="15.4dp" app:cardElevation="0dp" android:elevation="0dp" app:cardCornerRadius="9dp" android:layout_marginEnd="10dp" android:layout_marginStart="15.4dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:scaleType="centerCrop" android:src="@drawable/nearby_imgtwo"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16.2sp" android:textColor="#131314" android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:lineSpacingExtra="2.8sp" android:text="Ride" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="11.5sp" android:textColor="#8f8f8f" android:layout_gravity="center" android:layout_marginLeft="10dp" android:lineSpacingExtra="1.5sp" android:text="20 min" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="11.5sp" android:layout_marginRight="10dp" android:textColor="#8f8f8f" android:layout_gravity="center" android:lineSpacingExtra="1.5sp" android:gravity="end" android:text="52 m" /> </LinearLayout> <RatingBar android:layout_marginLeft="10dp" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_marginTop="10dp" android:layout_height="wrap_content" android:numStars="5" android:rating="4" android:layout_marginStart="10dp" /> </LinearLayout> </androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView android:layout_width="150dp" android:layout_marginTop="30dp" android:layout_height="214.2dp" android:layout_marginRight="10dp" android:layout_marginLeft="15.4dp" app:cardElevation="0dp" android:elevation="0dp" app:cardCornerRadius="9dp" android:layout_marginEnd="10dp" android:layout_marginStart="15.4dp"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_margin="10dp" android:scaleType="centerCrop" android:src="@drawable/nearby_imgthree"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="16.2sp" android:textColor="#131314" android:layout_marginLeft="10dp" android:layout_marginTop="5dp" android:lineSpacingExtra="2.8sp" android:text="Surfing" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textSize="11.5sp" android:textColor="#8f8f8f" android:layout_gravity="center" android:layout_marginLeft="10dp" android:lineSpacingExtra="1.5sp" android:text="45 min" /> <TextView android:layout_width="match_parent" android:layout_height="wrap_content" android:textSize="11.5sp" android:layout_marginRight="10dp" android:textColor="#8f8f8f" android:layout_gravity="center" android:lineSpacingExtra="1.5sp" android:gravity="end" android:text="37 m" /> </LinearLayout> <RatingBar android:layout_marginLeft="10dp" style="?android:attr/ratingBarStyleSmall" android:layout_width="wrap_content" android:layout_marginTop="10dp" android:layout_height="wrap_content" android:numStars="5" android:rating="4" android:layout_marginStart="10dp" /> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayout> </HorizontalScrollView> </RelativeLayout>
Step 04 :
Create toolbar_nearby.xml under res ⇒ layout and add the below values.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" android:fitsSystemWindows="true" android:orientation="vertical"> <androidx.cardview.widget.CardView android:id="@+id/search_bar" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="@dimen/spacing_middle" android:layout_marginLeft="@dimen/spacing_middle" android:layout_marginRight="@dimen/spacing_middle" android:layout_marginTop="@dimen/spacing_large" android:clipToPadding="false" app:cardBackgroundColor="@android:color/white" app:cardCornerRadius="3dp" app:cardElevation="3dp" app:cardUseCompatPadding="false" app:layout_collapseMode="parallax"> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal"> <ImageButton android:layout_width="?attr/actionBarSize" android:layout_height="?attr/actionBarSize" android:background="?attr/selectableItemBackgroundBorderless" android:tint="@color/grey_medium" app:srcCompat="@drawable/ic_menu_black_24dp" /> <TextView android:layout_width="0dp" android:layout_height="match_parent" android:layout_weight="1" android:gravity="center_vertical" android:text="Los Angeles" android:textAppearance="@style/Base.TextAppearance.AppCompat.Subhead" android:textColor="@color/textcolor" /> <ImageButton android:layout_width="?attr/actionBarSize" android:layout_height="?attr/actionBarSize" android:background="?attr/selectableItemBackgroundBorderless" app:srcCompat="@drawable/ic_mic_black_24dp" /> </LinearLayout> </androidx.cardview.widget.CardView> </LinearLayout>
Now run the app and see the output, you will see the nice nearby place Screen for your next Android Application with Android Source code.
So that’s all for this Nearby place Screen with Android Source code Tutorial. If you are having any confusion or queries please do comment. Thank You.