Scrollbars in custom view?

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Scrollbars in custom view?

Postby ypyean » Tue Apr 28, 2009 11:18 am

Hi everyone,

I am not sure whether someone has asked the question. If you know the solution, please advise me, thank you.

I refer to API Demo in android sdk to implement a custom view (com.example.android.apis.view.LabelView). I wish to add scroll bar in that custom view. I added android:scrollbars="vertical" in xml layout file. However, it did not display scroll bar as I expected.

xml layout file (from api demo):
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<com.example.android.apis.view.LabelView
android:background="@drawable/red"
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:scrollbars="vertical"
app:text="Red"/>
</LinearLayout>

Does anyone know the solution?
ypyean
Freshman
Freshman
 
Posts: 2
Joined: Tue Apr 28, 2009 11:04 am

Top

Postby alpesh_harsoda » Wed Apr 29, 2009 2:32 pm

HI,
just add the scroll view inside the linearlayout.inside this add the lableview.
Regards,
Alpesh Patel,
Logistic Infotech
http://www.logisticinfotech.com
User avatar
alpesh_harsoda
Senior Developer
Senior Developer
 
Posts: 106
Joined: Sat Sep 20, 2008 12:35 pm
Location: Rajkot,Gujarat(India)

Postby ypyean » Thu Apr 30, 2009 10:22 am

Hi alpesh_harsoda,

Thank you for replying.

I have tried your solution to add scroll view in xml layout file, but it did not work (neither show scrollbars nor can be scrolled).

The xml layout file I have modified as follows:

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
  4.        xmlns:app="http://schemas.android.com/apk/res/com.example.android.apis"
  5.  
  6.        android:orientation="vertical"
  7.  
  8.        android:layout_width="fill_parent"
  9.  
  10.        android:layout_height="wrap_content">
  11.  
  12.  
  13.  
  14.         <ScrollView android:layout_width="fill_parent"
  15.  
  16.                 android:layout_height="wrap_content" android:scrollbars="vertical" >    
  17.  
  18.             <com.example.android.apis.view.LabelView
  19.  
  20.                     android:background="@drawable/red"
  21.  
  22.                     android:layout_width="fill_parent"
  23.  
  24.                     android:layout_height="wrap_content" android:scrollbars="vertical"
  25.  
  26.                     app:text="Red"/>
  27.  
  28.     </ScrollView>    
  29.  
  30. </LinearLayout>
  31.  
  32.  
Parsed in 0.002 seconds, using GeSHi 1.0.8.4


Did I modify it correctly? I notice that LabelView has implement onDraw method to draw it's view. Is it possible that onDraw() method "overrided" the scrollbar?

Thank you for your help.
ypyean
Freshman
Freshman
 
Posts: 2
Joined: Tue Apr 28, 2009 11:04 am

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests