Layouts TP
Layouts TP
✓ FrameLayout
✓ LinearLayout
✓ TableLayout
✓ ScrollView
✓ HorizontalScrollView
✓ RelativeLayout
✓ ConstraintLayout
✓ GridLayout
</LinearLayout>
frameLayout with gravity
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="5dp">
<TextView
android:id="@+id/txtvw1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100dp"
android:layout_marginTop="10dp"
android:background="#286F24"
android:padding="10dp"
android:text="Login Details"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="80dp"
android:background="#ECEEE8"
android:hint="Enter your email"
android:padding="10dp" />
<EditText
android:id="@+id/editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="155dp"
android:background="#ECEEE8"
android:hint="Enter password"
android:padding="10dp" />
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="110dp"
android:layout_marginTop="240dp"
android:text="Submit" />
</FrameLayout>
Grid Layout
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:columnCount="4"
android:orientation="horizontal" >
<Button
android:layout_gravity="fill"
android:layout_column="0"
android:layout_columnSpan="3"
android:text="tttttttt" />
<Button
android:layout_column="3"
android:text="/" />
<Button android:text="1" />
<Button android:text="2" />
<Button android:text="3" />
<Button android:text="*" />
<Button android:text="4" />
<Button android:text="5" />
<Button android:text="6" />
<Button android:text="-" />
<Button android:text="7" />
<Button android:text="8" />
<Button android:text="9" />
<Button
android:layout_gravity="fill"
android:layout_rowSpan="3"
android:text="+" />
<Button
android:layout_gravity="fill"
android:layout_columnSpan="2"
android:text="0" />
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="sdssdsfsfs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs sdssdsfsfsffs
sdssdsfsfsffs ffs"/>
</LinearLayout>
ScrollView
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/m2isil"/>
</ScrollView>
Table layout
<?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="10dp"
android:paddingLeft="5dp"
android:paddingRight="5dp">
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Maste2 SI Project"
android:textSize = "20dp"
android:textStyle="bold">
</TextView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="5" />
</TableRow>
<TableRow android:background="#F0F7F7" 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="mob" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="3.5" />
</TableRow>
<TableRow android:background="#F0F7F7" 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="Zimbra" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="8" />
</TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="10" />
</TableRow>
</TableLayout>
ListView
ListViewAdapterImages.class
package com.example.addition;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import java.util.ArrayList;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.listviwwithapater);
MyListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view,int i , long l)
{
Intent intent=new
Intent(ListViewAdapterImages.this,listAdapternextactivity.class);
intent.putExtra("name",arrayList.get(i+1).getNumbersInText());
startActivity(intent);
};
});
}
OneViewInList
package com.example.addition;
// TextView 1
private String mNumberInDigit;
// TextView 1
private String mNumbersInText;
// create constructor to set the values for all the parameters of the each single
view
public OneViewInList(int NumbersImageId, String NumbersInDigit, String
NumbersInText) {
ivNumbersImageId = NumbersImageId;
mNumberInDigit = NumbersInDigit;
mNumbersInText = NumbersInText;
}
AdapterManager
package com.example.addition;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import java.util.ArrayList;
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
parent) {
// then according to the position of the view assign the desired TextView 1 for
the same
TextView textView1 = currentItemView.findViewById(R.id.textView1);
textView1.setText(currentNumberPosition.getNumberInDigit());
// then according to the position of the view assign the desired TextView 2 for
the same
TextView textView2 = currentItemView.findViewById(R.id.textView2);
textView2.setText(currentNumberPosition.getNumbersInText());
listviwwithapater
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#9E4242"
android:text="Master Isil Projects"
android:textAppearance="@style/TextAppearance.AppCompat.Body1"
android:textColor="#F1EBEB"
android:textSize="30dp" />
<ListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/listViewImage"
android:divider="@color/black"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
</ListView>
</LinearLayout>
adapter_list_item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="@+id/imageView"
android:layout_width="84dp"
android:layout_height="84dp"
android:padding="16dp"
tools:ignore="ContentDescription" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:gravity="bottom|left"
android:textColor="@android:color/black"
android:textSize="20sp"
android:textStyle="bold"
tools:ignore="RtlHardcoded" />
<TextView
android:id="@+id/textView2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:gravity="top|left"
android:textColor="@android:color/black"
android:textSize="20sp"
/>
</LinearLayout>
</LinearLayout>