Android Tutorial part-2- widgets
following are the important widgets used in android
- Button
- TextView
- ImageView
- EditText
- checkBox
- RadioButton
- ImageButton
Button widgets example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:text="submit"
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="20dip"
android:textColor="#ff0000"
android:gravity="right"
android:layout_gravity="right"
>
</Button>
</LinearLayout>
TextView widget Example
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:textStyle="bold"
android:textSize="25dip"
android:textColor="#FF0000"
android:gravity="right"
android:layout_gravity="right"
/>
</LinearLayout>
ImageView
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hjii"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="click"
android:textColor="#FF0000"
android:textSize="25dip"
android:textStyle="bold"
android:gravity="center"
android:layout_gravity="center"
/>
<ImageView
android:id="@+id/sach"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon">
</ImageView>
</LinearLayout>
Image Button
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hjii"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/icon"
android:id="@+id/sach"
/>
</LinearLayout>
EditText widget
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hjii"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:hint="Enter Your Name"
android:capitalize="words"
android:textColor="#ff0000"
android:textStyle="bold"
/>
</LinearLayout>
CheckBox
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hjii"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:hint="Enter Your Name"
android:capitalize="words"
android:textColor="#ff0000"
android:textStyle="bold"
/>
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream"
android:textStyle="bold"
/>
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream1"
android:textStyle="bold"
/>
<CheckBox
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream2"
android:textStyle="bold"
/>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click"
/>
</LinearLayout>
RadioButton
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/hjii"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<EditText
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dp"
android:hint="Enter Your Name"
android:capitalize="words"
android:textColor="#ff0000"
android:textStyle="bold"
/>
<RadioGroup
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream"
android:textStyle="bold"
android:id="@+id/sach"
/>
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream1"
android:textStyle="bold"
/>
<RadioButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="cream2"
android:textStyle="bold"
/>
</RadioGroup>
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Click"
/>
</LinearLayout>
No comments:
Post a Comment