2016-11-24 71 views
0

我在我的一个引用应用程序中使用RecyclerView和LinearLayout,如下所示。RecyclerView隐藏LinearLayout

<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" 
 
    > 
 

 

 
    <LinearLayout 
 
     android:background="@color/colorPrimary" 
 
     android:layout_alignParentBottom="true" 
 
     android:id="@+id/pageNavLayout" 
 
     android:orientation="horizontal" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="40dp"> 
 

 

 
     <RelativeLayout 
 
      android:layout_weight="1" 
 
      android:id="@+id/butPrev" 
 
      style="@style/SelectableItemBackground" 
 
      android:clickable="true" 
 
      android:layout_width="0dp" 
 
      android:layout_height="match_parent"> 
 

 
      <ImageView 
 
       android:layout_centerInParent="true" 
 
       android:scaleType="fitCenter" 
 
       android:src="@drawable/ic_keyboard_arrow_left_white_24dp" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent" /> 
 
     </RelativeLayout> 
 

 

 
     <View 
 
      android:background="#ffffff" 
 
      android:layout_width="1dp" 
 
      android:layout_height="match_parent"/> 
 

 
     <TextView 
 
      android:id="@+id/textPageCount" 
 
      android:clickable="true" 
 
      style="@style/SelectableItemBackground" 
 
      android:padding="8dp" 
 
      android:textSize="16sp" 
 
      android:textColor="@android:color/white" 
 
      android:text="Page 1 0f 67" 
 
      android:layout_width="wrap_content" 
 
      android:layout_height="wrap_content" /> 
 

 
     <View 
 
      android:background="#ffffff" 
 
      android:layout_width="1dp" 
 
      android:layout_height="match_parent"/> 
 

 
     <RelativeLayout 
 
      android:layout_weight="1" 
 
      style="@style/SelectableItemBackground" 
 
      android:clickable="true" 
 
      android:id="@+id/butNext" 
 
      android:layout_width="0dp" 
 
      android:layout_height="match_parent"> 
 

 
      <ImageView 
 
       android:layout_centerInParent="true" 
 
       android:src="@drawable/ic_keyboard_arrow_right_white_24dp" 
 
       android:layout_width="match_parent" 
 
       android:layout_height="match_parent" /> 
 
     </RelativeLayout> 
 

 
    </LinearLayout> 
 

 
    <android.support.v7.widget.RecyclerView 
 
     android:layout_marginTop="4dp" 
 
     android:layout_marginBottom="4dp" 
 
     android:layout_above="@id/pageNavLayout" 
 
     android:id="@+id/listQuoteView" 
 
     android:layout_width="match_parent" 
 
     android:layout_height="match_parent"></android.support.v7.widget.RecyclerView> 
 

 
</RelativeLayout>

现在,当我按下一个按钮和RecyclerView列表中的其他报价...它躲在我的LinearLayout了一段时间,当我把它的滚动,它显示它。我已将LinearLayout用于我的底部栏。我缺少的东西以及我应该做的事情总是显示最后一栏?

谢谢

+0

请问你可以用p ost你正在使用的代码? XML并没有告诉我们很多,例如你的隐藏元素或调整大小。 –

回答

0

添加android:layout_marginBottom="40dp"RecyclerView使其可见所有的时间,你的LinearLayout高度40dp(根据你的代码)。

0

试试这个。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    > 

    <android.support.v7.widget.RecyclerView 
     android:layout_marginTop="4dp" 
     android:layout_marginBottom="4dp" 
     android:id="@+id/listQuoteView" 
     android:layout_width="match_parent" 
     android:weight="1" 
     android:layout_height="0dp"> 
    </android.support.v7.widget.RecyclerView> 

<LinearLayout 
    android:orientation="vertical" 
    android:id="@+id/pageNavLayout" 
    android:layout_width="match_parent" 
    android:weight="1" 
    android:layout_height="0dp"> 

    <LinearLayout 
     android:background="@color/colorPrimary" 
     android:orientation="horizontal" 
     android:layout_width="match_parent" 
     android:layout_height="40dp"> 


     <RelativeLayout 
      android:layout_weight="1" 
      android:id="@+id/butPrev" 
      style="@style/SelectableItemBackground" 
      android:clickable="true" 
      android:layout_width="0dp" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_centerInParent="true" 
       android:scaleType="fitCenter" 
       android:src="@drawable/ic_keyboard_arrow_left_white_24dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
     </RelativeLayout> 


     <View 
      android:background="#ffffff" 
      android:layout_width="1dp" 
      android:layout_height="match_parent"/> 

     <TextView 
      android:id="@+id/textPageCount" 
      android:clickable="true" 
      style="@style/SelectableItemBackground" 
      android:padding="8dp" 
      android:textSize="16sp" 
      android:textColor="@android:color/white" 
      android:text="Page 1 0f 67" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 

     <View 
      android:background="#ffffff" 
      android:layout_width="1dp" 
      android:layout_height="match_parent"/> 

     <RelativeLayout 
      android:layout_weight="1" 
      style="@style/SelectableItemBackground" 
      android:clickable="true" 
      android:id="@+id/butNext" 
      android:layout_width="0dp" 
      android:layout_height="match_parent"> 

      <ImageView 
       android:layout_centerInParent="true" 
       android:src="@drawable/ic_keyboard_arrow_right_white_24dp" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" /> 
     </RelativeLayout> 

    </LinearLayout> 

</LinearLayout> 
</LinearLayout> 
0

下面是这固定到屏幕底部的元素的例子:

<RelativeLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:gravity="center" 
     android:background="#26ffffff" 
     android:paddingTop="3dp" 
     android:paddingBottom="3dp"> 
     <TextView 
      android:id="@+id/today_last_sync" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:textSize="12sp" 
      android:gravity="right" 
      android:textColor="@color/white"/> 
    </RelativeLayout> 

你需要确保你使用以下的孩子XML设置:

android:layout_alignParentBottom="true" 

除了父容器还有:

android:layout_width="match_parent" 
    android:layout_height="match_parent"