0
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Choose Details" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Year" android:id="@+id/textView2" android:layout_below="@+id/textView" android:layout_alignParentLeft="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Branch" android:id="@+id/textView3" android:layout_below="@+id/textView2" android:layout_alignParentLeft="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Semester" android:id="@+id/textView4" android:layout_below="@+id/textView3" android:layout_alignParentLeft="true"/> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView" android:layout_alignTop="@+id/textView2" android:layout_alignParentRight="true"/> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView2" android:layout_alignTop="@+id/textView4" android:layout_alignParentRight="true"/> <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView3" android:layout_below="@+id/textView4" android:layout_alignRight="@+id/scrollView2"/> </RelativeLayout> 

I am bit new to android.Could anyone tel me that why arent the three scroll bars visible along the text views.I want to display the scrolls adjacent to their respective textviews.Moreover is the relative layout the best way to align the widgets .

0

4 Answers 4

1

Until and unless, you add View element in ScrollView, the ScrollViews which u have added cannot be visible, but they are present in layout. ScrollView must contain a single View item either it is a LinearLayout, RelativeLayout with child views such as TextView, ImageView, EditText, Button as below:

<ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView2" android:layout_alignTop="@+id/textView4" android:layout_alignParentRight="true"> <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <ImageView android:id="@+id/image1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" /> </LinearLayout> </ScrollView> 

or a View element as a single child for ScrollView as below:

 <ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/scrollView2" android:layout_alignTop="@+id/textView4" android:layout_alignParentRight="true"> <ImageView android:id="@+id/image1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp"/> </LinearLayout> </ScrollView> 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks @RaghuRamiReddy . I hope the person who asked question can understand what i have explained here and accepts the answer..!!!
@user2474232 do u find the solution??
0

A scroll view is not a scroll bar.

It must contain some elements.

Example :

 <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_below="@+id/imageView1" > <LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Button" /> <Button android:id="@+id/button2" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Button" /> <Button android:id="@+id/button3" android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginTop="10dp" android:text="Button" /> </LinearLayout> </ScrollView> 

Your code should be

<ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="Choose Details" android:id="@+id/textView" android:layout_alignParentTop="true" android:layout_centerHorizontal="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Year" android:id="@+id/textView2" android:layout_below="@+id/textView" android:layout_alignParentLeft="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Branch" android:id="@+id/textView3" android:layout_below="@+id/textView2" android:layout_alignParentLeft="true"/> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceMedium" android:text="Semester" android:id="@+id/textView4" android:layout_below="@+id/textView3" android:layout_alignParentLeft="true"/> <ScrollView/> 

Comments

0

The ScrollView in your layout is not visible because your it does not contain any widget with height and width. If you want to see your ScrollView then you have to set some value to the width and height (for example android:layout_width="40dip") properties, and a backgroundColor(), after this you will able to see you ScrollView.

Comments

0

1) Use LinearLayout instead of RelativeLayout, set android:orientation="vertical"

2) Put the textview inside your scrollview, like this:

<ScrollView android:layout_width="wrap_content" android:layout_height="wrap_content"> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" ... </TextView> </ScrollView> 

If you put all textviews inside a single scrollview, you will have one scrollbar(Note however that scrollview can only contain one child view, so you'll need to wrap those textviews under a linear layout); if you put one text view in each scrollview and stack those scrollviews vertically in linear layout, then you'll have separate scrollbar for each textview.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.