2015-08-31 110 views
0

我做了一個佈局,在頂部有一個listView和其他元素,當我打開這個佈局時,屏幕將重點放在linearLayout上,它就像它在linearLayout上設置的滾動,它有一個如何將滾動設置到佈局的頂部?Iniciolice佈局頂部位置

<?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 
 
\t \t layout= "@layout/tool_bar" 
 
\t \t android:layout_height= "wrap_content" 
 
\t \t android:layout_width= "match_parent"/> 
 

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

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

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

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

 
    </LinearLayout> 
 
    </ScrollView> 
 
</LinearLayout>

+0

請分享XML佈局,第一 – LaurentY

+0

對不起,它的存在,現在 – GusDev

回答

0

您有另一個滾動型(滾動型)內的滾動視圖(ListView控件)。

scrollView linearlayout and listview

列表視圖不應該放在一個滾動型裏面,因爲ListView控件 類實現了自己的滾動,它只是不接收 手勢,因爲他們都得到由父滾動型處理。 但是,您可以將要滾動到ListView的視圖添加爲 標題或頁腳。

另一個線程談論這個: https://stackoverflow.com/a/3496042/4559849

+0

好的,謝謝,我會重拍我的佈局 – GusDev