Widget Recent Post No.

header ads

Android Studio Tutorial - Yoga Fitness and weight loss App | Include Source Code


 Step 1 home.xml


<?xml version="1.0" encoding="utf-8"?>

<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"

    android:orientation="vertical"

    android:background="@drawable/background"

    tools:context=".home.Homes_fragment">






    <RelativeLayout

        android:layout_width="match_parent"

        android:layout_height="match_parent"

        android:orientation="vertical">



        <androidx.appcompat.widget.Toolbar

            android:background="#f3c623"


            android:id="@+id/toolbar"

            android:layout_width="match_parent"

            android:layout_height="wrap_content" />




    </RelativeLayout>





    <androidx.constraintlayout.widget.ConstraintLayout

        android:layout_marginTop="0dp"


        android:layout_width="match_parent"

        android:layout_height="match_parent">




        <ScrollView

            android:orientation="vertical"

            android:layout_width="match_parent"

            android:layout_height="match_parent">



            <LinearLayout

                android:background="@drawable/ic_homebg"

                android:orientation="vertical"

                android:layout_width="match_parent"

                android:layout_height="match_parent">




                <TextView


                    android:layout_marginTop="30dp"

                    android:paddingLeft="20dp"

                    android:id="@+id/text1"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:orientation="vertical"

                    android:gravity="center"

                    android:text="Yoga Workout Every Day"

                    android:textSize="35dp"

                    android:textStyle="bold"

                    android:fontFamily="sans-serif-condensed"

                    android:textColor="#000" />


                <TextView

                    android:layout_marginTop="15dp"

                    android:drawableRight="@drawable/stop"

                    android:id="@+id/stop_watch"

                    android:layout_width="wrap_content"

                    android:layout_height="40dp"

                    android:orientation="vertical"

                    android:text="Stop Watch"

                    android:textSize="24sp"

                    android:layout_gravity="center"

                    android:fontFamily="sans-serif-condensed"

                    android:textColor="#000" />






                <LinearLayout


                    android:layout_marginTop="4dp"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:paddingBottom="16dp"

                    android:orientation="vertical">


                    <HorizontalScrollView

                        android:layout_width="match_parent"

                        android:layout_height="wrap_content"

                        android:scrollbars="none">


                        <LinearLayout

                            android:layout_width="match_parent"

                            android:layout_height="wrap_content"

                            android:layout_marginTop="55sp"

                            android:padding="12dp">



                            <Button

                                android:id="@+id/btn_yoga1"

                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/suryanamaskar" />


                            <Button

                                android:id="@+id/yoga2"

                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/suryanamaskar" />

                            <Button


                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/suryanamaskar" />

                            <Button


                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/suryanamaskar" />



                            <Button


                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/suryanamaskar" />

                            <Button


                                android:textColor="#fff"

                                android:layout_width="100dp"

                                android:layout_height="100dp"

                                android:layout_marginRight="4dp"

                                android:background="@drawable/yoga1" />



                        </LinearLayout>


                    </HorizontalScrollView>



                </LinearLayout>




                <TextView


                    android:paddingLeft="20dp"


                    android:id="@+id/text4"

                    android:layout_width="match_parent"

                    android:layout_height="wrap_content"

                    android:text="Category"

                    android:textColor="#1E1010"

                    android:textSize="20sp"

                    android:fontFamily="sans-serif-condensed"/>




                <LinearLayout


                    android:layout_width="match_parent"

                    android:layout_height="match_parent"

                    android:orientation="vertical">



                    <LinearLayout

                        android:layout_width="match_parent"

                        android:layout_height="wrap_content"

                        android:orientation="horizontal"

                        android:weightSum="3">

                        <LinearLayout

                            android:layout_width="0dp"

                            android:layout_height="120dp"

                            android:layout_weight="1"

                            android:layout_margin="2dp"

                            android:orientation="vertical">


                            <Button

                                android:layout_width="100dp"

                                android:layout_height="match_parent"

                                android:layout_marginTop="20dp"

                                android:layout_gravity="center"

                                android:background="@drawable/kids"/>






                        </LinearLayout>


                        <LinearLayout

                            android:layout_width="0dp"

                            android:layout_height="120dp"

                            android:layout_weight="1"

                            android:layout_margin="2dp"

                            android:orientation="vertical"


                            >


                            <Button

                                android:layout_width="100dp"

                                android:layout_height="match_parent"

                                android:layout_marginTop="20dp"

                                android:layout_gravity="center"

                                android:background="@drawable/young"/>



                        </LinearLayout>


                        <LinearLayout

                            android:layout_width="0dp"

                            android:layout_height="120dp"

                            android:layout_weight="1"

                            android:layout_margin="2dp"

                            android:orientation="vertical">


                            <Button

                                android:layout_width="100dp"

                                android:layout_height="match_parent"

                                android:layout_marginTop="20dp"

                                android:layout_gravity="center"

                                android:background="@drawable/mature"/>


                        </LinearLayout>



                    </LinearLayout>




                    <TextView


                        android:paddingLeft="20dp"

                        android:layout_marginTop="20dp"

                        android:id="@+id/text5"

                        android:layout_width="match_parent"

                        android:layout_height="wrap_content"

                        android:text="Choose Your Plan"

                        android:textColor="#1E1010"

                        android:textSize="20sp"

                        android:fontFamily="sans-serif-condensed"/>




                    <Button

                        android:layout_gravity="center"

                        android:id="@+id/beginner_yoga1"

                        android:layout_width="350dp"

                        android:layout_height="150dp"

                        android:background="@drawable/yoga_beginner"/>



                    <Button

                        android:layout_gravity="center"

                        android:id="@+id/inter_yoga2"

                        android:layout_width="350dp"

                        android:layout_height="150dp"

                        android:background="@drawable/yoga_inter"/>



                    <Button

                        android:layout_gravity="center"

                        android:id="@+id/advance_yoga1"

                        android:layout_width="350dp"

                        android:layout_height="150dp"

                        android:background="@drawable/yoga_advance"/>




                </LinearLayout>








            </LinearLayout>





        </ScrollView>



    </androidx.constraintlayout.widget.ConstraintLayout>





</RelativeLayout>



Step 2 home.java

package in.brandvidiya.yogaforweightloss.home;


import android.content.Context;

import android.content.Intent;

import android.os.Bundle;


import androidx.fragment.app.Fragment;


import android.view.LayoutInflater;

import android.view.View;

import android.view.ViewGroup;

import android.widget.Button;

import android.widget.TextView;


import in.brandvidiya.yogaforweightloss.R;

import in.brandvidiya.yogaforweightloss.joining_from;

import in.brandvidiya.yogaforweightloss.mainpage.MainActivity;

import in.brandvidiya.yogaforweightloss.stopwatch.stop_watch_page;



public class Homes_fragment extends Fragment {

    Button btn_yoga1,yoga2;

    TextView stop_watch;

    Context context;


    @Override

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {


        View view = inflater.inflate(R.layout.fragment_homes_fragment, container, false);

        context = view.getContext();



        stop_watch = view.findViewById(R.id.stop_watch);

        stop_watch.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                Intent intent = new Intent(context.getApplicationContext(), stop_watch_page.class);

                startActivity(intent);

            }

        });




        btn_yoga1 = view.findViewById(R.id.btn_yoga1);

        btn_yoga1.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                Intent intent = new Intent(context.getApplicationContext(), joining_from.class);

                startActivity(intent);

            }

        });


        yoga2 = view.findViewById(R.id.yoga2);

        yoga2.setOnClickListener(new View.OnClickListener() {

            @Override

            public void onClick(View view) {

                Intent intent = new Intent(context.getApplicationContext(), MainActivity.class);

                startActivity(intent);

            }

        });




        return view;

    }



}


READ MORE >>

GITHUB : https://github.com/LearncodeWithRk/YogaforWeightLoss

Post a Comment

0 Comments