ontal and vertical layout use
Linear horizontal and vertical layout use
To we study about XML linear and horizontal layouts.
To day goal :-
1.What is horizontal and vertica layouts
2. Mixing of layouts
Horizontal layouts:-
Horizontal layouts contain x-axis components .
1. Drag and drop linear layouts
And drag and drop all function like this.
Same as vertical case:-
Mixing of layouts
1.drag and drop horizontal and go to property section and change the hight of layouts select parent .
After this drag and drop 3 vertical layout on horizontal and also drag and drop which function you want in app from widgets look like this:-
App all XML and java code:-
package com.my.newproject2;
import android.app.*;
import android.os.*;
import android.view.*;
import android.view.View.*;
import android.widget.*;
import android.content.*;
import android.content.ClipboardManager;
import android.graphics.*;
import android.media.*;
import android.net.*;
import android.text.*;
import android.util.*;
import android.webkit.*;
import android.animation.*;
import android.view.animation.*;
import java.util.*;
import java.text.*;
public class MainActivity extends Activity {
private LinearLayout linear4;
private LinearLayout linear7;
private LinearLayout linear8;
private LinearLayout linear9;
private ImageView imageview9;
private ImageView imageview10;
private ImageView imageview11;
private ImageView imageview12;
private ImageView imageview13;
private ImageView imageview14;
private ImageView imageview15;
private Button button8;
private Button button9;
private Button button10;
private ImageView imageview16;
private ImageView imageview17;
private CheckBox checkbox2;
private EditText edittext1;
private TextView textview1;
private ArrayList<String> first = new ArrayList<String>();
private ArrayList<HashMap<String, String>> map1 = new ArrayList<>();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
initialize();
initializeLogic();
}
private void initialize() {
linear4 = (LinearLayout) findViewById(R.id.linear4);
linear7 = (LinearLayout) findViewById(R.id.linear7);
linear8 = (LinearLayout) findViewById(R.id.linear8);
linear9 = (LinearLayout) findViewById(R.id.linear9);
imageview9 = (ImageView) findViewById(R.id.imageview9);
imageview10 = (ImageView) findViewById(R.id.imageview10);
imageview11 = (ImageView) findViewById(R.id.imageview11);
imageview12 = (ImageView) findViewById(R.id.imageview12);
imageview13 = (ImageView) findViewById(R.id.imageview13);
imageview14 = (ImageView) findViewById(R.id.imageview14);
imageview15 = (ImageView) findViewById(R.id.imageview15);
button8 = (Button) findViewById(R.id.button8);
button9 = (Button) findViewById(R.id.button9);
button10 = (Button) findViewById(R.id.button10);
imageview16 = (ImageView) findViewById(R.id.imageview16);
imageview17 = (ImageView) findViewById(R.id.imageview17);
checkbox2 = (CheckBox) findViewById(R.id.checkbox2);
edittext1 = (EditText) findViewById(R.id.edittext1);
textview1 = (TextView) findViewById(R.id.textview1);
button8.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
}
});
button9.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
}
});
button10.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View _v) {
}
});
}
private void initializeLogic() {
first.add(“knh”);
first.add(“youtube”);
{
HashMap<String, String> _item = new HashMap<String, String>();
_item.put(“key”, “anytext”);
map1.add(_item);
}
}
// created automatically
private void showMessage(String _s) {
Toast.makeText(getApplicationContext(), _s, Toast.LENGTH_SHORT).show();
}
private int getRandom(int _minValue ,int _maxValue){
Random random = new Random();
return random.nextInt(_maxValue – _minValue + 1) + _minValue;
}
public ArrayList<Double> getCheckedItemPositionsToArray(ListView _list) {
ArrayList<Double> _result = new ArrayList<Double>();
SparseBooleanArray _arr = _list.getCheckedItemPositions();
for (int _iIdx = 0; _iIdx < _arr.size(); _iIdx++) {
if (_arr.valueAt(_iIdx))
_result.add((double)_arr.keyAt(_iIdx));
}
return _result;
}
private float getDip(int _input){
return TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, _input, getResources().getDisplayMetrics());
}
private int getDisplayWidthPixels(){
return getResources().getDisplayMetrics().widthPixels;
}
private int getDisplayHeightPixels(){
return getResources().getDisplayMetrics().heightPixels;
}
}
<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:orientation=”vertical”
>
<LinearLayout
android:id=”@+id/linear4″
android:layout_width=”match_parent”
android:layout_height=”match_parent”
android:padding=”8dp”
android:background=”#FFF176″
android:orientation=”horizontal”
>
<LinearLayout
android:id=”@+id/linear7″
android:layout_width=”wrap_content”
android:layout_height=”match_parent”
android:padding=”8dp”
android:background=”#FFCDD2″
android:orientation=”vertical”
>
<ImageView
android:id=”@+id/imageview9″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<ImageView
android:id=”@+id/imageview12″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<ImageView
android:id=”@+id/imageview15″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<Button
android:id=”@+id/button10″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:text=”Button”
android:textSize=”12sp”
android:textColor=”#000000″
/>
<ImageView
android:id=”@+id/imageview16″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
</LinearLayout>
<LinearLayout
android:id=”@+id/linear8″
android:layout_width=”wrap_content”
android:layout_height=”match_parent”
android:padding=”8dp”
android:background=”#90CAF9″
android:orientation=”vertical”
>
<ImageView
android:id=”@+id/imageview10″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<ImageView
android:id=”@+id/imageview13″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<Button
android:id=”@+id/button9″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:text=”Button”
android:textSize=”12sp”
android:textColor=”#000000″
/>
<ImageView
android:id=”@+id/imageview17″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<CheckBox
android:id=”@+id/checkbox2″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:text=”CheckBox”
android:textSize=”12sp”
android:textColor=”#000000″
/>
</LinearLayout>
<LinearLayout
android:id=”@+id/linear9″
android:layout_width=”wrap_content”
android:layout_height=”match_parent”
android:padding=”8dp”
android:background=”#A5D6A7″
android:orientation=”vertical”
>
<ImageView
android:id=”@+id/imageview11″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<ImageView
android:id=”@+id/imageview14″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/default_image”
android:scaleType=”center”
/>
<Button
android:id=”@+id/button8″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:text=”Button”
android:textSize=”12sp”
android:textColor=”#000000″
/>
<EditText
android:id=”@+id/edittext1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:textSize=”12sp”
android:textColor=”#000000″
android:hint=”Edit Text”
android:textColorHint=”#607D8B”
/>
<TextView
android:id=”@+id/textview1″
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:padding=”8dp”
android:text=”TextView”
android:textSize=”12sp”
android:textColor=”#000000″
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
xmlns:android=”http://schemas.android.com/apk/res/android”
android:layout_width=”match_parent”
android:layout_height=”wrap_content”
android:orientation=”vertical”
>
<ImageView
android:id=”@+id/imageview1″
android:focusable=”false”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:src=”@drawable/kkkk”
android:scaleType=”center”
/>
</LinearLayout>
<manifest xmlns:android=”http://schemas.android.com/apk/res/android”
package=”com.my.newproject2″>
<application android:allowBackup=”true”
android:label=”custom”
android:icon=”@drawable/app_icon”
android:name=”.SketchApplication”
android:theme=”@style/AppTheme”>
<activity
android:name=”.MainActivity”
android:configChanges=”orientation|screenSize”
android:screenOrientation=”portrait”
>
<intent-filter>
<action android:name=”android.intent.action.MAIN”/>
<category android:name=”android.intent.category.LAUNCHER”/>
</intent-filter>
</activity>
<activity android:name=”.DebugActivity” android:screenOrientation=”portrait”/>
</application>
</manifest>
Comments
Post a Comment