Blog purpose for android basic example for android app developer. any query please my contact

Tuesday, 20 April 2021

android studio table layout example

 android studio table layout example

In this tutorial Today Learn android studio table layout example. follow the full source code android studio table layout example.


1.Open Android Studio and Create a New Project follow the fig:



android studio table layout example



2.Choice a Empty Activity and click next:



android studio table layout example




3.Renam a Project Name and package name. click finish.



android studio table layout example





4.Tablelayout.java:


package com.akash.myapplication;


import androidx.appcompat.app.AppCompatActivity;


import android.os.Bundle;


public class Tablelayout extends AppCompatActivity {


    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_tablelayout);

    }

}


5.activity_tablelayout.xml:

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

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"

    android:layout_width="match_parent"

    android:layout_height="match_parent"

    android:layout_marginTop="100dp"

    android:paddingLeft="10dp"

    android:paddingRight="10dp" >

    <TableRow android:background="#0079D6" android:padding="5dp">

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="UserId" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="User Name" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="Password" />

    </TableRow>

    <TableRow android:background="#DAE8FC" android:padding="5dp">

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="1" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="Akash" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="akash123" />

    </TableRow>

    <TableRow android:background="#DAE8FC" android:padding="5dp">

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="2" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="Prakash" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="prakash123" />

    </TableRow>

    <TableRow android:background="#DAE8FC" android:padding="5dp">

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="3" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="Vijay" />

        <TextView

            android:layout_width="wrap_content"

            android:layout_height="wrap_content"

            android:layout_weight="1"

            android:text="vijay123" />

    </TableRow>

</TableLayout>



6.AndroidManifest.xml:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.akash.myapplication">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".Tablelayout">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>


7.colors.xml:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <color name="colorPrimary">#6200EE</color>
    <color name="colorPrimaryDark">#3700B3</color>
    <color name="colorAccent">#03DAC5</color>
</resources>

8.strings.xml:

<resources>
    <string name="app_name">table layout example</string>
</resources>

9.Output:


android studio table layout example






No comments:

Post a Comment