• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to add a scrollbar to a view

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear folks,

I am not able to work with the scrolls which I have added in my XML file called choice.xml. This XML file has a set of radio buttons and an exit button. I have written the following code for choice.xml file:


choice.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="700dip" android:orientation="vertical" android:id="@+id/linearLayout">
<TextView android:layout_width="wrap_content" android:textSize="15sp" android:id="@+id/textView1" android:layout_height="wrap_content" android:text="@string/strChoice"></TextView>
<ScrollView android:id="@+id/scrollView1" android:layout_height="600dip" android:layout_width="fill_parent">
<RadioGroup android:id="@+id/radioGroup1" android:layout_width="wrap_content" android:layout_height="wrap_content">
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optFiveLetterWord" android:text="@string/strFiveLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optSixLetterWord" android:text="@string/strSixLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optSevenLetterWord" android:text="@string/strSevenLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optEightLetterWord" android:text="@string/strEightLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optNineLetterWord" android:text="@string/strNineLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optTenLetterWord" android:text="@string/strTenLetterWord"></RadioButton>
<RadioButton android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/optTwelveLetterWord" android:text="@string/strTwelveLetterWord"></RadioButton>
</RadioGroup>
</ScrollView>
<RelativeLayout android:layout_marginTop="-50dip" android:gravity="bottom" android:layout_height="wrap_content" android:layout_width="fill_parent">
<Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/btnExit" android:text="@string/strExit"></Button>
</RelativeLayout>
</LinearLayout>

I have not written any code in Choice.java which is an Activity class and corresponds to choice.xml. When I test the application after installing in the android phone, the scroll is not working. It does not work for portrait as well as the landscape orientation.

I know that I have to write the code in Choice.java but don't know what to write and how to use the ScrollView. Please help.
 
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually scrollbar comes in picture only when view is not fits into the screen. Your code is correct to test it add more radio buttons then you will see the scrollbar.
 
sohaib rahman
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes Pramod,
The suggestion you had given me is true for portrait orientation, but when the orientation changes to landscape the remaining radio buttons go down and I am not able to scroll. What now?
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
sohaib in landscape mode also you can see the scrollbar. I can see on my emulator.
 
sohaib rahman
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
here is the screenshot of the view
Filename: img.bmp
File size: 236 Kbytes
 
Pramod P Deore
Ranch Hand
Posts: 633
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
try to scroll the screen by using mouse wheel or by using keyboard. Here I can see the scrollbars in both mode.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic