NDT*_*DTS 3 java xml android android-layout android-recyclerview
所以我在布局文件中遇到了一些RecyclerView问题
这里是:
Run Code Online (Sandbox Code Playgroud)<android.support.v7.widget.RecyclerView android:id="@+id/chat_listview" android:layout_width="match_parent" android:layout_height="wrap_content" android:paddingRight="@dimen/abc_action_bar_default_padding_material" android:paddingLeft="@dimen/abc_action_bar_default_padding_material" /> <LinearLayout android:layout_below="@id/chat_listview" android:layout_width="match_parent" android:layout_height="@dimen/bottom_bar_height" android:orientation="horizontal" > <EditText android:id="@+id/chat_input_edittext" android:layout_weight="7" android:layout_width="0dp" android:layout_height="match_parent" android:inputType="textAutoCorrect" /> <Button android:id="@+id/chat_send_button" android:layout_weight="1" android:layout_width="0dp" android:layout_height="match_parent" android:background="@drawable/ic_action_send_now" /> </LinearLayout>
RecyclerView是可见的和可滚动的但是LinearLayout和里面的视图是不可见的...我尝试了很多东西,但到目前为止还没有任何工作.
你们中的任何人都可以指出我正确的方向吗?
提前谢谢了!
绘制RecyclerView时,它会在绘制下一个元素之前计算屏幕上的所有剩余大小,并且在绘制其他元素后不再重新计算,将它们留在屏幕外.
诀窍是先绘制所有其他元素,然后将RecyclerView留到最后.FrameLayout不再起作用,因此使用相对布局并将RecyclerView放在XML布局文件的最后.
在RecyclerView下面添加带按钮的栏的示例:
<?xml version="1.0" encoding="utf-8"?>
<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"
android:padding="16dp"
tools:context=".MainActivity"
>
<LinearLayout
android:id="@+id/pagination_btns"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true"> //HERE YOU ALIGN THIS ELEMENT TO THE BOTTOM OF THE PARENT
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/previous_btn_label"/>
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"/>
<Button
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/next_btn_label"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/items_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_above="@id/pagination_btns"/> //HERE YOU ALIGN THE RECYCLERVIEW ABOVE THE PAGINATION BAR
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2757 次 |
| 最近记录: |