2016-09-15 87 views
0

下面是底部工作表的布局文件。我在嵌套滚动视图下面有一个TextView。当内容很大时,NestedScrollView下的TextView不可见。如果NestedScrollView的内容很小,则可见。我没有得到什么导致这一点。TextView下面的NestedScrollView与高度wrap_content不可见

这是我的布局文件:

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="@color/white" 
     android:orientation="vertical"> 

     <android.support.v7.widget.Toolbar 
      android:id="@+id/bottom_sheet_toolbar" 
      android:layout_width="match_parent" 
      android:layout_height="?attr/actionBarSize" 
      android:paddingLeft="@dimen/activity_horizontal_margin" 
      android:paddingRight="@dimen/activity_horizontal_margin" 
      app:popupTheme="@style/AppTheme.PopupOverlay" 
      app:title="My Title"> 

      <ImageView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_gravity="end" 
       android:background="?attr/selectableItemBackgroundBorderless" 
       android:onClick="@{() -> handler.hideBottomSheet()}" 
       android:src="@drawable/ic_keyboard_arrow_down_black_24dp" /> 

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

     <LinearLayout 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" 
      android:paddingLeft="@dimen/activity_horizontal_margin" 
      android:paddingRight="@dimen/activity_horizontal_margin"> 

      <RadioGroup 
       android:id="@+id/selection_mode" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="10dp" 
       android:checkedButton="@+id/mode_1" 
       android:gravity="center" 
       android:orientation="horizontal"> 

       <RadioButton 
        android:id="@+id/mode_1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/mode_1" /> 

       <RadioButton 
        android:id="@+id/mode_2" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/mode_2" /> 

      </RadioGroup> 

      <android.support.v4.widget.NestedScrollView 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content"> 

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

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

      <TextView 
       android:id="@+id/list_description" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_marginBottom="20dp" 
       android:layout_marginTop="10dp" 
       android:gravity="center" 
       android:text="This text is not visible. I dunno why! :/" /> 

     </LinearLayout> 

    </LinearLayout> 
</FrameLayout> 

list_container LinerLayout膨胀上运行。有一些原因我没有使用RecyclerViewListView。这是相当小的,只是稍微滚动一下。

但是当list_container很大(需要滚动)时TextView list_description未显示。

我不明白发生了什么问题。

回答

1

尝试在您的NestedScrollView上使用android:layout_weight

在你的情况下,更换您的NestedScrollView头:

<android.support.v4.widget.NestedScrollView 
       android:layout_width="match_parent" 
       android:layout_height="0dp" 
       android:layout_weight="1" 

希望帮助=]

+1

真棒!这工作!谢谢! – kirtan403

相关问题