0

I'm making a layout with a listView and other elements at the top, when i open this layout, the screen focus on the linearLayout, it's like the scroll it's set on the linearLayout, its there a way to set the scroll just to the top of the layout?

<?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="fill_parent"
    android:background="@color/White"
    android:orientation="vertical" >

    <include
  layout= "@layout/tool_bar"
  android:layout_height= "wrap_content"
  android:layout_width= "match_parent"/>

    <ScrollView 
        android:id="@+id/scroll"
        android:layout_width="match_parent"
     android:layout_height="fill_parent"> 
     

    <LinearLayout 
        android:layout_width="match_parent"
     android:layout_height="fill_parent"
     android:orientation="vertical">        
     
    <TextView 
     android:layout_width= "fill_parent"
     android:layout_height= "wrap_content"
     android:text= "NOTIFICATIONS"
     android:textSize= "10dp"
     android:layout_margin= "10dp"
     
  />
 <View
    android:layout_widt = "fill_parent"
    android:layout_height= "1dp"
    android:background= "@android:color/darker_gray"/>
    <RelativeLayout 
     android:layout_width= "fill_parent"
     android:layout_height= "wrap_content"  
     android:paddingRight= "12dp">
     <TextView
         android:id= "@+id/general_notifications"
      style= "@style/bold"    
      android:paddingLeft= "20dp"
      android:paddingTop= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/Notifications"     
      android:layout_alignParentStart= "true"
      android:textColor= "@color/date_left"
      android:textSize= "18dp"/>     
     <TextView         
      style= "@style/light"    
      android:paddingStart= "20dp"
      android:paddingBottom= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/global_notifications_text"     
      android:layout_below= "@+id/general_notifications"
      android:textColor= "@color/date_left"/>
     
  <Switch 
      android:id= "@+id/global_notification_switch"      
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:layout_alignParentEnd= "true"      
      android:padding= "18dp"/>
 </RelativeLayout>
    <View          
     android:layout_width= "fill_parent"
     android:layout_height= "1dp"
     android:background= "@android:color/darker_gray"/>
    
    <RelativeLayout 
     android:layout_width= "fill_parent"
     android:layout_height= "wrap_content"  
     android:paddingRight= "12dp"
     android:onClick= "selectWifi">
     <TextView
         android:id= "@+id/wi_fi"
      style= "@style/bold"    
      android:paddingStart= "20dp"
      android:paddingTop= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/WiFi"     
      android:layout_alignParentStart= "true"
      android:textColor= "@color/date_left"
      android:textSize= "18dp"/>     
     <TextView         
         android:id= "@+id/wifi_name"
      style= "@style/light"    
      android:paddingTop= "20dp"
      android:paddingStart= "5dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"          
      android:layout_toEndOf= "@+id/wi_fi"
      android:layout_alignBaseline= "@+id/wi_fi"
      android:textColor= "@color/date_left"/>
     
     <TextView         
         android:id= "@+id/wifi_explaining_text"
      style= "@style/light"    
      android:paddingStart= "20dp"
      android:paddingBottom= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/wifi_settings"     
      android:layout_below= "@+id/wi_fi"
      android:textColor= "@color/date_left"/>

 </RelativeLayout>
    <View          
     android:layout_width= "fill_parent"
     android:layout_height= "1dp"
     android:background= "@android:color/darker_gray"/>
    
     <RelativeLayout 
     android:layout_width= "fill_parent"
     android:layout_height= "wrap_content"  
     android:paddingRight= "12dp"
     android:onClick= "setTime">
     <TextView
         android:id= "@+id/notifications_hours"
      style= "@style/bold"    
      android:paddingStart= "20dp"
      android:paddingTop= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/not_hours"     
      android:layout_alignParentStart= "true"
      android:textColor= "@color/date_left"
      android:textSize= "18dp"/>
     
     <TextView         
         android:id= "@+id/hours_data"
      style= "@style/light"    
      android:paddingTop= "20dp"
      android:paddingStart= "5dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"          
      android:layout_toEndOf= "@+id/notifications_hours"
      android:layout_alignBaseline= "@+id/notifications_hours"
      android:textColor= "@color/date_left"/>
     
     <TextView         
      style= "@style/light"    
      android:paddingStart= "20dp"
      android:paddingBottom= "20dp"
      android:layout_width= "wrap_content"
      android:layout_height= "wrap_content"
      android:text= "@string/not_hours_text"     
      android:layout_below= "@+id/notifications_hours"
      android:textColor= "@color/date_left"/>

 </RelativeLayout>
    <View          
     android:layout_width= "fill_parent"
     android:layout_height= "1dp"
     android:background= "@android:color/darker_gray"/>
     <TextView 
     android:layout_width="fill_parent"
     android:layout_height="wrap_content"
     android:text="APPS"
     android:textSize="10dp"
     android:layout_margin="10dp"/>
 <View
     android:layout_width="fill_parent"
     android:layout_height="1dp"
     android:background="@android:color/darker_gray"/>  
     
    <ListView
        android:id="@+id/listview"
        android:layout_width="fill_parent"
        android:layout_height="305dp" />

    </LinearLayout>
    </ScrollView>
</LinearLayout>
GusDev
  • 255
  • 6
  • 20

1 Answers1

0

You have a scrollview (ListView) inside another scrollview (ScrollView).

scrollView linearlayout and listview :

ListViews shouldn't be placed inside a ScrollView because the ListView class implements its own scrolling and it just doesn't receive gestures because they all get handled by the parent ScrollView. However you can add views you want to be scrolled to the ListView as headers or footers.

Another thread talking about this: https://stackoverflow.com/a/3496042/4559849

Community
  • 1
  • 1
LaurentY
  • 7,495
  • 3
  • 37
  • 55