She*_*kar 0 android android-recyclerview
设计布局RecycleView用于显示图像.下面添加了一个按钮RecycleView以保存列表中的所选项目.在设计视图中和运行应用程序时,按钮不可见.无法追踪问题所在.代码是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true"
tools:context="com.example.user.recycleview.imagesview">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:theme="@style/AppTheme.AppBarLayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/titlebar"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<view
android:layout_width="fill_parent"
android:layout_height="fill_parent"
class="android.support.v7.widget.RecyclerView"
android:id="@+id/recycler_view" />
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="@drawable/savebutton"
android:text="@string/save"
android:textColor="@color/white"
android:textSize="12pt" />
<!--
Deleted fab element
-->
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
1.添加RelativeLayout下面AppBarLayout,把Button和RecyclerView里面RelativeLayout.
2.添加属性android:layout_alignParentBottom="true"以Button在bottom屏幕上对齐它.
3.添加属性android:layout_above="@id/button7"以RecyclerView显示上面的内容Button.
更新您的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:fitsSystemWindows="true">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:theme="@style/AppTheme.AppBarLayout">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="@color/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Save"
android:textColor="@android:color/black" />
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@id/button7"/>
</RelativeLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
OUTPUT:
| 归档时间: |
|
| 查看次数: |
573 次 |
| 最近记录: |