5 Linear Layout
Algorithm:
Step 1) Create a new Android Studio Project named as linearlayout.
Step 2)Goto Project Structure and open activity_main.xml file
Step 3) Remove the default layout i.e Constraint layout and create Linear Layout by using tag or drag and drop from the palette.
Step 3) Create a TextView, ImageView, and Button in Activity_main.xml file or drag and drop from the palette.
Step 4) Add Image to the res/drawable folder and supported filenames are lowercase and
names are allowed. Ex: klu_thins.jpg
names are allowed. Ex: klu_thins.jpg
Step 5) Run the application from the menu bar select Run and Click on Run App option.
Program: Activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" xmlns:android="http://schemas.android.com/apk/res/android">
<TextView android:id="@+id/textView"
android:layout_width="match_parent" android:layout_height="wrap_content" android:textAlignment="center" android:text="Welcome to Android Sessions" />
<ImageView android:id="@+id/imageView" android:layout_width="match_parent" android:layout_height="wrap_content"
app:srcCompat="@drawable/Klthings" />
<Button android:id="@+id/button"
android:layout_width="match_parent" android:layout_height="wrap_content" android:text="Android" />
</LinearLayout>
MainActivity.java
package com.example.linearlayout;
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);
}
}
Comments
Post a Comment