2016-08-09 20 views
-2

Ich muss sowohl die horizontale Listenansicht als auch die vertikale Listenansicht in einer einzelnen Aktivität scrollen.Scrollen Sie zwei horizontale Listenansichten und eine vertikale Listenansicht in einer einzigen Aktivität.

Im Folgenden werde ich einen Screenshot für die Beiträge geschrieben haben:

enter image description here

activity_main.xml:

<ScrollView 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/home_layout_top" 
     android:scrollbars="none" 
     > 

     <RelativeLayout 
      android:id="@+id/rl_container_scroll" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content"> 

      <include 
       android:id="@+id/inc_ads_horizon" 
       layout="@layout/ads_horizontal_listview_layout" 
       android:layout_width="match_parent" 
       android:layout_height="50dp" 
       android:layout_marginTop="10dp" /> 

      <include 
       android:id="@+id/inc_people_know" 
       layout="@layout/people_you_know_layout" 
       android:layout_width="match_parent" 
       android:layout_height="50dp" 
       android:layout_below="@+id/inc_ads_horizon" 
       android:layout_marginTop="10dp" /> 


      <include 
       android:id="@+id/inc_listview" 
       layout="@layout/tab_home_list_view" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@+id/inc_people_know" 
       android:layout_marginTop="10dp" /> 


      <TextView 
       android:id="@+id/no_user_posts_item_tv" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerInParent="true" 
       android:text="@string/txt_no_posts_available" 
       android:textColor="@color/txt_common_black" 
       android:textSize="@dimen/txt_size" /> 

     </RelativeLayout> 

    </ScrollView> 

tab_home_list_view.xml:

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

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/home_layout_bottom" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_margin="10dp" 
    android:orientation="vertical"> 

    <ListView 
     android:id="@+id/lv_post_home_tab" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:divider="@null" 
     android:dividerHeight="5dp" 
     android:scrollbars="none" 
     android:transcriptMode="alwaysScroll" 
     android:visibility="gone" /> 


</LinearLayout> 

ads_horizontal_listview_layout.xml:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rl_horizontalscroll_child" 
    android:layout_width="fill_parent" 
    android:layout_height="50dp" 
    android:layout_below="@+id/rl_horizontalscroll_parent" 
    android:layout_marginTop="40dp"> 

    <com.steve.thirdparty.HorizontalListView 
     android:id="@+id/hlv_child" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 

people_you_know_layout.xml:

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

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/rl_horizontalscroll_second_child" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_below="@+id/rl_horizontalscroll_parent" 
    android:layout_marginTop="40dp"> 

    <com.steve.thirdparty.HorizontalListView 
     android:id="@+id/hlv_child" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" /> 

</RelativeLayout> 

ich mit scrollview.It versucht, ist mir nicht möglich kennen zu scroll.Let ist es noch andere Möglichkeiten zu lösen dieses Problem.

Wenn ich vertikale Listenansicht nach oben scrolle, scrollt es nur vertikale Listenansicht. Wenn ich horizontale Listenansicht nach oben scrolle, ist es sowohl vertikale und horizontale Liste scrollen. Aber wenn ich scrolling, ist horizontale Listenansicht hiden.

+0

Verwenden 'android.support.v4.widget.NestedScrollView' anstelle von' ScrollView' – JavaGhost

+1

Verwenden RecyclerView für bessere Scroll-Kontrolle. http://blog.inapptext.com/recyclerview-creating-dynamic-lists-and-grids-in-android-1/ –

+0

@ JavaGhost es nicht gelöst.Wenn ich vertikale Listenansicht nach oben scrollen, ist es vertikal scrollen listview only. Wenn ich horizontale Listenansicht nach oben scrolle, scrollt es sowohl in vertikaler als auch in horizontaler Liste. Aber wenn ich scogle, ist horizontale Listenansicht hiden. – Steve

Antwort

0

verwenden xml Layout Artikel Ansichten nach Ihrem tatsächlichen Bedarf anpassen:

<?xml version="1.0" encoding="utf-8"?> 
<android.support.v4.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:nestedScrollingEnabled="true"> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 
     <!-- You can define layout manager here also--> 
     <android.support.v7.widget.RecyclerView 
      android:id="@+id/ads_horizon" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:layout_marginTop="10dp" 
      app:layoutManager="android.support.v7.widget.LinearLayoutManager"/> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/people_know" 
      android:layout_width="match_parent" 
      android:layout_height="50dp" 
      android:orientation="horizontal" 
      android:layout_marginTop="10dp" 
      app:layoutManager="android.support.v7.widget.LinearLayoutManager"/> 

     <android.support.v7.widget.RecyclerView 
      android:id="@+id/post_home_tab" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:orientation="vertical" 
      android:layout_marginTop="10dp" 
      app:layoutManager="android.support.v7.widget.LinearLayoutManager"/> 
    </LinearLayout> 

</android.support.v4.widget.NestedScrollView>