2016-08-08 36 views
0

Ich habe versucht, Tutorial für ScrollView in ScrollView zu suchen, und ich fand viele, aber niemand für mich arbeiten. Das ist mein Layout unten. Die zweite ScrollView (id = scroll_view_carousel) funktioniert nicht. Bitte hilf mir.ScrollView innerhalb ScrollView funktioniert nicht

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout 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" 
    android:orientation="vertical" 
    tools:context="com.rytmus.app.activities.DetailsActivity"> 

    <android.support.design.widget.AppBarLayout 
     android:id="@+id/appbar" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/white" 
     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="@color/white" 
      android:theme="@style/Toolbar" 
      app:collapseIcon="@drawable/ic_arrow_back_white_24dp" 
      app:layout_scrollFlags="scroll|enterAlways" 
      app:title="Rytmus" 
      app:titleTextColor="@color/colorPrimary"> 

     </android.support.v7.widget.Toolbar> 

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

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

     <RelativeLayout 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_margin="0dp"> 

      <ImageView 
       android:id="@+id/big_logo" 
       android:layout_width="match_parent" 
       android:layout_height="160dp" 
       android:scaleType="centerCrop" /> 

      <ScrollView 
       android:id="@+id/scroll_view_carousel" 
       android:layout_width="match_parent" 
       android:layout_height="75dp" 
       android:layout_below="@id/big_logo" 
       android:background="@color/colorBlack"> 

       <LinearLayout 
        android:layout_width="match_parent" 
        android:layout_height="60dp" 
        android:layout_marginTop="5dp" 
        android:orientation="horizontal"> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/ic_arrow_back_white_24dp" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/com_facebook_button_like_background" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

        <ImageView 
         android:layout_width="60dp" 
         android:layout_height="60dp" 
         android:layout_marginRight="5dp" 
         android:scaleType="centerCrop" 
         android:src="@drawable/background_rytmus_disco" /> 

       </LinearLayout> 

      </ScrollView> 

      <LinearLayout 
       android:id="@+id/four_buttons" 
       android:layout_width="match_parent" 
       android:layout_height="46dp" 
       android:layout_below="@id/scroll_view_carousel" 
       android:background="@color/colorAccent" 
       android:orientation="horizontal"> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/tabFirstsButtonsLinearLayout" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:orientation="vertical"> 


       </LinearLayout> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="100dp" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" /> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/tabSecondsButtonsLinearLayout" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_centerHorizontal="true" 
        android:layout_weight="1" 
        android:orientation="vertical"> 


       </LinearLayout> 

      </LinearLayout> 

      <LinearLayout 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="vertical"> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/tabs_disco_details" 
       android:layout_width="match_parent" 
       android:layout_height="46dp" 
       android:layout_below="@id/four_buttons" 
       android:background="@color/colorPrimary" 
       android:orientation="horizontal"> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/tabDescriptionLinearLayout" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_weight="1" 
        android:orientation="vertical"> 

        <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/tabDescription" 
         android:layout_width="wrap_content" 
         android:layout_height="match_parent" 
         android:layout_gravity="center" 
         android:layout_margin="4dp" 
         android:gravity="center" 
         android:paddingLeft="10dp" 
         android:text="Descripción" 
         android:textColor="@color/white" 
         android:textSize="13sp" /> 
       </LinearLayout> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="90dp" 
        android:layout_height="fill_parent" 
        android:orientation="vertical" /> 

       <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:id="@+id/tabValorationLinearLayout" 
        android:layout_width="fill_parent" 
        android:layout_height="fill_parent" 
        android:layout_centerHorizontal="true" 
        android:layout_weight="1" 
        android:orientation="vertical"> 

        <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
         android:id="@+id/tabValoration" 
         android:layout_width="wrap_content" 
         android:layout_height="match_parent" 
         android:layout_gravity="center" 
         android:layout_margin="4dp" 
         android:gravity="center" 
         android:paddingLeft="10dp" 
         android:text="Valoraciones" 
         android:textColor="@color/white" 
         android:textSize="13sp" /> 
       </LinearLayout> 

      </LinearLayout> 

      <LinearLayout 
       android:id="@+id/container_fragment" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_below="@id/tabs_disco_details" 
       android:orientation="vertical" /> 

      <LinearLayout 
       android:layout_width="101dp" 
       android:layout_height="101dp" 
       android:layout_below="@id/scroll_view_carousel" 
       android:layout_centerHorizontal="true" 
       android:background="@drawable/border" 
       android:translationY="-5dp"> 

       <ImageView 
        android:id="@+id/imagen_logo" 
        android:layout_width="100dp" 
        android:layout_height="100dp" 
        android:layout_centerHorizontal="true" 
        android:src="@drawable/background_rytmus_disco" /> 

      </LinearLayout> 

     </RelativeLayout> 

    </ScrollView> 
</LinearLayout> 

SOLUTION

ich das zweite Scroll für ein HorizontalScrollView ändern und arbeiten jetzt !!!

+0

nur lineare Layout als Kind der Bildlaufansicht, nicht relatives Layout –

Antwort

0

Sehr schlechte Programmierpraxis. Sie können scrollView in scrollView nicht einbetten.

im Allgemeinen ListView in scrollView funktioniert auch nicht, weil ListView seine eigene Scroll-Funktionalität hat und wir es wieder in scrollView-Klasse einbetten, weshalb es Jerk erstellen wird.

gleich in diesem wie sollte man scrollView in scrollView integrieren? logisch denken, wie es möglich sein sollte? wird es verwirren, welche scrollView ausgelöst wird?

-1

Lesen Sie über ScrollView.

ScrollView ist eine spezielle Art von Layout, entworfen, um Ansicht größer als seine tatsächliche Größe zu halten. Wenn die Größe der Ansichten die ScrollView-Größe überschreitet, fügt sie automatisch Bildlaufleisten hinzu und kann vertikal gescrollt werden. ScrollView kann nur ein direktes Kind enthalten. Das heißt, wenn Sie ein komplexes Layout mit mehr Steuerelementen für die Ansicht haben, müssen Sie sie in ein anderes Standardlayout wie LinearLayout, TableLayout oder RelativeLayout einschließen. Sie können layout_height und layout_width angeben, um Höhe und Breite des Bildschirms anzupassen.

Scrollview ist ideal für Bildschirme, in denen Scrollen erforderlich ist, aber es ist ein Overhead, wenn die Scroll-Ansicht zum Rendern einer größeren Liste von Daten verwendet wird. Android bietet spezielle Adapteransichten wie ListView, GridView und RecyclerView (eingeführt in Android Lollipop) für lange Listen.

Sie sollten niemals eine ScrollView mit einem ListView oder GridView verwenden, da beide sich um ihr eigenes vertikales Scrollen kümmern. ScrollView unterstützt nur vertikales Scrollen. HorizontalScrollView wird für horizontales Scrollen verwendet.

Die Eigenschaft android:fillViewport definiert, ob der ScrollView seinen Inhalt so strecken soll, dass er das Ansichtsfenster ausfüllt. Sie können dieselbe Eigenschaft festlegen, indem Sie die Methode setFillViewport (boolean) von der Java-Klasse aufrufen.

Verwenden Sie nicht scrollview in scrollview ... möglicherweise über Dokumente helfen Ihnen!

Verwandte Themen