Hello guys, In this tutorial, we will see how to create activity with textview, image view and add long text or description or how to include a paragraph in an activity.
Step 1: Create a new project in an android studio.
Step 4: Select any activity for your project to start with coding. I have selected empty activity here.
Step 5: MainActivity will be your default and necessary activity.
Step 6: After clicking "Finish", we will be able to get started with our application coding.
We all know how to add text to activity but now we will see how to add long text or description or paragraph to our android activity.
Below is the code for this project.
MainActivity.java :
package com.sharayusuryawanshi.lenovo.android_paragraph;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
Make sure to change your package name to avoid errors.
activity_main.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:id="@+id/activity_balasana"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sharayusuryawanshi.lenovo.android_paragraph.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/wallp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="15dp"
android:gravity="center"
android:text="ANDROID HISTORY"
android:textColor="#e71616"
android:textSize="30dp"
android:id="@+id/textView" />
<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="270dp"
android:layout_alignParentStart="true"
android:layout_below="@+id/textView"
android:layout_marginTop="17dp"
android:src="@drawable/andyrobo">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_below="@+id/imageView"
android:text="
The version history of the Android mobile operating system began with the public release of the Android beta on November 5, 2007. The first commercial version, Android 1.0, was released on September 23, 2008. Android is continually developed by Google and the Open Handset Alliance, and it has seen a number of updates to its base operating system since the initial release.
Versions 1.0 and 1.1 were not released under specific code names, although Android 1.1 was unofficially known as Petit Four. Android code names are confectionery-themed and have been in alphabetical order since 2009's Android 1.5 Cupcake, with the most recent major version being Android 9.0 Pie, released in August 2018."
android:textColor="#FFFFFF"
android:textSize="20dp" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Comments
Post a Comment