User Interface. Scroll View

ScrollView  permite afişarea în cadrul aceluiaş screen a unui număr foarte mare de controale, după cum şi numele induce ideea de scroll, de extindere a interfeţei grafice.

ScrollView:

Determină expandarea screen-ului pe verticală.

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="15dip"
android:gravity="center_horizontal">
<TextView android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exemplu ScrollView"
android:paddingBottom="15dip"
android:textSize="20dp">
</TextView>
<ImageView android:id="@+id/img1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/green_1"
android:layout_below="@id/txt"
android:layout_marginBottom="15dip">
</ImageView>
<ImageView android:id="@+id/img2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/blue_1"
android:layout_below="@id/img1"
android:layout_marginBottom="15dip">
</ImageView>
<ImageView android:id="@+id/img3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/orange_1"
android:layout_below="@id/img2">
</ImageView>
</RelativeLayout>
</ScrollView>

Rulând aplicaţia care conţine acest fişier xml se va afişa:

HorizontalScrollView:

Permite expandarea view-ului pe orizontală.

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Exemplu HorizontalScrollView"
android:textSize="20dp"
android:paddingRight="20dip">
</TextView>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Optiunea 1">
</RadioButton>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Optiunea 2">
</RadioButton>
</LinearLayout>
</HorizontalScrollView>

Se va afişa:

Ca observaţie importantă, trebuie reţinut faptul că atunci când utilizăm ScrollView singurul “copil” ierarhic poate fi reprezentat fie de LinearLayout, fie de RelativeLayout.

Advertisements
User Interface. Scroll View

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s