2016-08-19 4 views
-2

Ich habe eine NestedScrollview in einem CoordinatorLayout. Jetzt gibt es 5-6 Ansichten innerhalb von NestedScrollview und die Sichtbarkeit wird abhängig von den Daten über das Netzwerk ändern. Das Problem ist, dass scrollview immer die gleiche Höhe (insgesamt alle 5-6 Ansichten) und lässt eine leere Stelle am unteren Rand, wenn ich die Sichtbarkeit einer Ansicht ausblenden. Könnten Sie mir bitte sagen, wie ich die Höhe des Scrollview anpassen kann, so dass es keinen leeren Platz am unteren Rand des Scrollview gibt.Android Scrollview Höhe Dynamische Anpassung

<android.support.design.widget.CoordinatorLayout 
    android:id="@+id/main_content" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:fitsSystemWindows="true" 
    android:orientation="vertical"> 

<android.support.design.widget.AppBarLayout 
    android:id="@+id/MyAppbar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@android:color/white" 
    android:fitsSystemWindows="true"> 

    <android.support.design.widget.CollapsingToolbarLayout 
     android:id="@+id/collapse_toolbar" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:fitsSystemWindows="true" 
     app:collapsedTitleGravity="center_horizontal" 
     app:expandedTitleGravity="center_horizontal" 
     app:layout_scrollFlags="scroll|exitUntilCollapsed"> 

     <!--Some content here--> 

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

<android.support.v4.widget.NestedScrollView 
    android:id="@+id/nested_scroll_view" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    app:layout_behavior="@string/appbar_scrolling_view_behavior"> 

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

     <include 
      android:id="@+id/profile_extra_details" 
      layout="@layout/profile_extra_details_layout" /> 

     <LinearLayout 
      android:id="@+id/see_project_listing_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 

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

      <ViewSwitcher 
       android:id="@+id/work_switcher" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

       <include 
        android:id="@+id/see_project_listing" 
        layout="@layout/photos_with_heading" /> 

       <TextView 
        android:id="@+id/txt_no_work_found" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:layout_gravity="center" 
        android:gravity="center" 
        android:text="There are no Design Boards" 
        /> 
      </ViewSwitcher> 

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

Dies ist NestedScrollview. Unten ist das profile_extra_details_layout. Dies ist das Layout, dessen Sichtbarkeit basierend auf der Datenverfügbarkeit aus dem Netzwerk und dem Typ des Benutzers, dessen Profil angezeigt wird, gesteuert wird.

<?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="wrap_content" 
    android:orientation="vertical"> 

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

    <TextView 
     android:id="@+id/user_description" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="@dimen/activity_horizontal_margin" 
     android:layout_marginRight="@dimen/activity_horizontal_margin" 
     android:visibility="gone" /> 

    <LinearLayout 
     android:id="@+id/location_buget_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center_horizontal" 
     android:gravity="center" 
     android:orientation="horizontal" 
     android:visibility="visible"> 

     <LinearLayout 
      android:id="@+id/ll_budget_yearEstb" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:visibility="gone"> 

      <ImageView 
       android:id="@+id/img_budget_yearEstb" 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_gravity="center_horizontal" 
       android:src="@drawable/id_proejct_budget" /> 

      <TextView 
       android:id="@+id/txt_budget_yearEstb" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" /> 

     </LinearLayout> 

     <LinearLayout 
      android:id="@+id/ll_location" 
      android:layout_width="0dp" 
      android:layout_height="wrap_content" 
      android:layout_weight="1" 
      android:orientation="vertical" 
      android:visibility="gone"> 

      <ImageView 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:layout_gravity="center_horizontal" 
       android:padding="5dp" 
       android:src="@drawable/id_project_city" /> 

      <TextView 
       android:id="@+id/location" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="center_horizontal" 
       android:padding="5dp" 
       android:text="Mumbai,India" 
       android:textStyle="bold" /> 
     </LinearLayout> 

    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/individual_firm_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:visibility="gone"> 

     <ImageView 
      android:layout_width="@dimen/image_size_beside_text" 
      android:layout_height="@dimen/image_size_beside_text" 
      android:src="@drawable/id_expert_firm_ind" /> 

     <TextView 
      android:id="@+id/individual_firm_txt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Firm/Individual" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/awards_ll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:orientation="horizontal" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:visibility="gone"> 

     <ImageView 
      android:layout_width="@dimen/image_size_beside_text" 
      android:layout_height="@dimen/image_size_beside_text" 
      android:src="@drawable/id_expert_awards" /> 

     <TextView 
      android:id="@+id/awards_txt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/web_add_ll" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:visibility="gone"> 

     <ImageView 
      android:layout_width="@dimen/image_size_beside_text" 
      android:layout_height="@dimen/image_size_beside_text" 
      android:src="@drawable/id_seller_web" /> 

     <TextView 
      android:id="@+id/web_add_txt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Abc.xyz" /> 
    </LinearLayout> 

    <LinearLayout 
     android:id="@+id/ll_location_ho" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_vertical" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:visibility="gone"> 

     <ImageView 
      android:layout_width="@dimen/image_size_beside_text" 
      android:layout_height="@dimen/image_size_beside_text" 
      android:src="@drawable/id_project_city" /> 

     <TextView 
      android:id="@+id/location_ho_txt" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Abc.xyz" /> 
    </LinearLayout> 
</LinearLayout> 

Bitte lassen Sie mich wissen, wenn ich mehr überall ausarbeiten muss.

+0

Ohne irgendwelche Codes oder Bildstruktur oder etwas, wir können Ihnen nicht helfen. Deshalb kümmern sich die Leute nicht darum. – Cyrex

+0

Probieren Sie dies aus, aber Sie können nicht garantieren, dass dies in Ihrem Fall die Lösung ist. http://www.dreamincode.net/forums/topic/130521-android-part-iii-dynamic-layouts/ – Cyrex

Antwort

0

Sie Dies würde helfen: , wenn Sie die Ansicht Verwendung View.GONE verstecken, ich glaube, Sie nestedscrollview Höhe View.INVISIBLE

+0

Nein, ich verwende nur View.GONE. Ich möchte nicht View.INVISIBLE, weil das wird Leerraum in der Mitte des Layouts erstellen – user2601981

+0

Verstecken Sie Ansichten oder lineares Layout? Weil Sie Ansichten innerhalb des linearen Layouts verwenden – VNS

+0

Ich verstecke beide Ansichten sowie LinearLayout, falls in diesem LinearLayout nichts angezeigt werden soll – user2601981

0

Versuch zu ändern, um zu match_parent und das Kind lineare Layout Höhe wrap_content verwenden. Danach ändern Sie die Sichtbarkeit des untergeordneten Layouts des linearen Layouts zur Laufzeit.