2016-03-23 6 views
0

Hi bin versuchen, Scroll zu meiner Aktivität hinzuzufügen.Android Scroll-Ansicht geht über die APP-Leiste

Meine Tätigkeit hat zwei Dateien

1) activity_temple_details

2) content_temple_details

Wenn ich zu blättern versuchen. Der Inhalt ist über der App-Leiste sichtbar.

wie diese

enter image description here

Ich möchte den Inhalt hinter dem appbar oder disapper gehen, während

hier Scrollen ist mein Code

activity_temple_details

<?xml version="1.0" encoding="utf-8"?> 



    <android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     xmlns:app="http://schemas.android.com/apk/res-auto" 
     xmlns:tools="http://schemas.android.com/tools" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details"> 

     <android.support.design.widget.AppBarLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:theme="@style/AppTheme.AppBarOverlay"> 

      <android.support.v7.widget.Toolbar 
       android:id="@+id/toolbar" 
       android:layout_width="match_parent" 
       android:layout_height="?attr/actionBarSize" 
       android:background="?attr/colorPrimary" 
       app:popupTheme="@style/AppTheme.PopupOverlay" /> 

     </android.support.design.widget.AppBarLayout> 



     <include layout="@layout/content_temple__details" /> 



    </android.support.design.widget.CoordinatorLayout> 

content_temple_details

<?xml version="1.0" encoding="utf-8"?> 

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" android:layout_height="fill_parent"> 

    <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" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:layout_centerInParent="true" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details" 
     tools:showIn="@layout/activity_temple__details"> 





     <ImageView 
      android:layout_width="120dp" 
      android:layout_height="120dp" 
      android:id="@+id/IV_temple_logo" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:src="@drawable/ic_action_movie" 
      android:background="@drawable/image_view_style" 
      android:layout_marginRight="5dp"/> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Temple Name" 
      android:id="@+id/textView" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:layout_marginLeft="8dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_title" 
      android:layout_below="@+id/textView" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:textSize="14dp" 
      android:layout_marginLeft="8dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Address" 
      android:id="@+id/textView3" 
      android:layout_below="@+id/TV_title" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="8dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_address" 
      android:layout_below="@+id/textView3" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:textSize="14dp" 
      android:layout_marginLeft="8dp" /> 






     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Description" 
      android:id="@+id/textView5" 
      android:layout_below="@+id/IV_temple_logo" 
      android:layout_alignRight="@+id/IV_temple_logo" 
      android:layout_alignEnd="@+id/IV_temple_logo" 
      android:layout_marginTop="10dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_Description" 
      android:layout_below="@+id/textView5" 
      android:layout_alignRight="@+id/TV_title" 
      android:layout_alignEnd="@+id/TV_title" 
      android:background="@drawable/textview_style" 
      android:textSize="14dp" 
      android:layout_marginTop="8dp" 
      android:scrollbars = "vertical"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Directions" 
      android:id="@+id/button" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_marginTop="70dp" 
      android:layout_below="@+id/TV_Description" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Search Again" 
      android:id="@+id/button2" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_alignTop="@+id/button" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" /> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Suggest an Edit" 
      android:id="@+id/button3" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_below="@+id/button" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_marginTop="15dp" /> 




    </RelativeLayout> 
    </ScrollView> 

kann jemand mir helfen, dieses Problem zu beheben. Tnx.

+1

sollten Sie "verschachtelte Scroll-Ansicht" verwenden und innen, die das Layout ohne Scroll umfassen – kishorepatel

Antwort

0

/* Ändern Sie es entsprechend Ihrer Anforderung **/

<RelativeLayout 
    android:id="@+id/relative_activity_main" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 

    android:orientation="vertical" 
    android:background="@color/mainBackGroundColor" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <LinearLayout 
     android:id="@+id/linearlayout1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:orientation="vertical"> 
    <include 
      android:id="@+id/app_bar_id" 
      layout="@layout/app_bar"></include> 
    <include 
      android:id="@+id/yourlayout_id" 
      layout="@layout/yourLayout"></include> 
</LinearLayout> 
</RelativeLayout> 
+0

Tnx. Aber das ist Arbeit. gibt die gleichen Ergebnisse. –

0

Im CoordinatorLayout Sie haben NestedScrollView aber nicht Scrollview zu verwenden, ist hier Ihre Lösung

content_temple_details.xml

<?xml version="1.0" encoding="utf-8"?> 

<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" android:layout_height="fill_parent"> 

<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" 
    android:paddingBottom="@dimen/activity_vertical_margin" 
    android:paddingLeft="@dimen/activity_horizontal_margin" 
    android:paddingRight="@dimen/activity_horizontal_margin" 
    android:layout_centerInParent="true" 
    android:paddingTop="@dimen/activity_vertical_margin" 
    tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details" 
    tools:showIn="@layout/activity_temple__details"> 

    <ImageView 
     android:layout_width="120dp" 
     android:layout_height="120dp" 
     android:id="@+id/IV_temple_logo" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:src="@drawable/ic_action_movie" 
     android:background="@drawable/image_view_style" 
     android:layout_marginRight="5dp"/> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Temple Name" 
     android:id="@+id/textView" 
     android:layout_alignParentTop="true" 
     android:layout_toRightOf="@+id/IV_temple_logo" 
     android:layout_toEndOf="@+id/IV_temple_logo" 
     android:layout_marginLeft="8dp" 
     android:textSize="14dp" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Large Text" 
     android:id="@+id/TV_title" 
     android:layout_below="@+id/textView" 
     android:layout_toRightOf="@+id/IV_temple_logo" 
     android:layout_toEndOf="@+id/IV_temple_logo" 
     android:textSize="14dp" 
     android:layout_marginLeft="8dp" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Address" 
     android:id="@+id/textView3" 
     android:layout_below="@+id/TV_title" 
     android:layout_toRightOf="@+id/IV_temple_logo" 
     android:layout_toEndOf="@+id/IV_temple_logo" 
     android:layout_marginTop="10dp" 
     android:layout_marginLeft="8dp" 
     android:textSize="14dp" /> 

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Large Text" 
     android:id="@+id/TV_address" 
     android:layout_below="@+id/textView3" 
     android:layout_toRightOf="@+id/IV_temple_logo" 
     android:layout_toEndOf="@+id/IV_temple_logo" 
     android:textSize="14dp" 
     android:layout_marginLeft="8dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Description" 
     android:id="@+id/textView5" 
     android:layout_below="@+id/IV_temple_logo" 
     android:layout_alignRight="@+id/IV_temple_logo" 
     android:layout_alignEnd="@+id/IV_temple_logo" 
     android:layout_marginTop="10dp" 
     android:textSize="14dp" /> 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Large Text" 
     android:id="@+id/TV_Description" 
     android:layout_below="@+id/textView5" 
     android:layout_alignRight="@+id/TV_title" 
     android:layout_alignEnd="@+id/TV_title" 
     android:background="@drawable/textview_style" 
     android:textSize="14dp" 
     android:layout_marginTop="8dp" 
     android:scrollbars = "vertical"/> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Directions" 
     android:id="@+id/button" 
     android:background="@drawable/button_selector" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" 
     android:textSize="18dp" 
     android:layout_marginTop="70dp" 
     android:layout_below="@+id/TV_Description" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Search Again" 
     android:id="@+id/button2" 
     android:background="@drawable/button_selector" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" 
     android:textSize="18dp" 
     android:layout_alignTop="@+id/button" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentEnd="true" /> 

    <Button 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Suggest an Edit" 
     android:id="@+id/button3" 
     android:background="@drawable/button_selector" 
     android:textColor="@android:color/white" 
     android:textStyle="bold" 
     android:textSize="18dp" 
     android:layout_below="@+id/button" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginTop="15dp" /> 
</RelativeLayout> 
</android.support.v4.widget.NestedScrollView> 
1

Versuchen Sie, folgende Zeile in scrollview

hinzuzufügen
android:layout_marginTop="?attr/actionBarSize" 

Ich denke, es wird helfen, Es löste mein Problem.

Layout-Datei

<?xml version="1.0" encoding="utf-8"?> 

    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
    android:layout_marginTop="?attr/actionBarSize" 

> 

    <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" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:layout_centerInParent="true" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     tools:context="baman.lankahomes.lk.jaffnatemples.Temple_Details" 
     tools:showIn="@layout/activity_temple__details"> 





     <ImageView 
      android:layout_width="120dp" 
      android:layout_height="120dp" 
      android:id="@+id/IV_temple_logo" 
      android:layout_alignParentTop="true" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:src="@drawable/ic_action_movie" 
      android:background="@drawable/image_view_style" 
      android:layout_marginRight="5dp"/> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Temple Name" 
      android:id="@+id/textView" 
      android:layout_alignParentTop="true" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:layout_marginLeft="8dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_title" 
      android:layout_below="@+id/textView" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:textSize="14dp" 
      android:layout_marginLeft="8dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Address" 
      android:id="@+id/textView3" 
      android:layout_below="@+id/TV_title" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:layout_marginTop="10dp" 
      android:layout_marginLeft="8dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_address" 
      android:layout_below="@+id/textView3" 
      android:layout_toRightOf="@+id/IV_temple_logo" 
      android:layout_toEndOf="@+id/IV_temple_logo" 
      android:textSize="14dp" 
      android:layout_marginLeft="8dp" /> 






     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceMedium" 
      android:text="Description" 
      android:id="@+id/textView5" 
      android:layout_below="@+id/IV_temple_logo" 
      android:layout_alignRight="@+id/IV_temple_logo" 
      android:layout_alignEnd="@+id/IV_temple_logo" 
      android:layout_marginTop="10dp" 
      android:textSize="14dp" /> 

     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:textAppearance="?android:attr/textAppearanceLarge" 
      android:text="Large Text" 
      android:id="@+id/TV_Description" 
      android:layout_below="@+id/textView5" 
      android:layout_alignRight="@+id/TV_title" 
      android:layout_alignEnd="@+id/TV_title" 
      android:background="@drawable/textview_style" 
      android:textSize="14dp" 
      android:layout_marginTop="8dp" 
      android:scrollbars = "vertical"/> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Directions" 
      android:id="@+id/button" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_marginTop="70dp" 
      android:layout_below="@+id/TV_Description" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" /> 

     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Search Again" 
      android:id="@+id/button2" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_alignTop="@+id/button" 
      android:layout_alignParentRight="true" 
      android:layout_alignParentEnd="true" /> 

     <Button 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:text="Suggest an Edit" 
      android:id="@+id/button3" 
      android:background="@drawable/button_selector" 
      android:textColor="@android:color/white" 
      android:textStyle="bold" 
      android:textSize="18dp" 
      android:layout_below="@+id/button" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentStart="true" 
      android:layout_marginTop="15dp" /> 




    </RelativeLayout> 
    </ScrollView> 
Verwandte Themen