如何在底部的linearlayout中放置相对布局
我刚刚创建了一个线性布局作为父布局,并且还在此父线性布局内创建了一个相对布局,我只需要将此相对布局的粉红色置于这里的线性布局 的底部是我的xml文件如何在底部的linearlayout中放置相对布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="abtech.waiteriano.com.waitrer.MenuActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:gravity="bottom"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@drawable/fire" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
试试这个代码
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
tools:context="abtech.waiteriano.com.waitrer.MenuActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- <FrameLayout
android:id="@+id/content_frame"
android:layout_width="matc
h_parent"
android:layout_height="wrap_content"></FrameLayout>-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="bottom">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/relativeLayout"/>
<RelativeLayout
android:id="@+id/relativeLayout"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:background="#ff6b6b">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@drawable/fire" />
</RelativeLayout>
</RelativeLayout>
非常感谢@Rahul Giradkar,实际上我需要的是 –
@ Dev.7arooney接受这个回答 –
但是有一个问题,相关的布局显示在列表视图下,我需要这个来显示列表,这意味着在框架布局@Rahul Giradkar ,去检查我的编辑我发布在图片中的问题 –
<LinearLayout 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:orientation="vertical"
tools:context="abtech.waiteriano.com.waitrer.MenuActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="0dp" <-----changed here
android:layout_weight="1"> <-----and here
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ff6b6b">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@drawable/fire" />
</RelativeLayout>
</RelativeLayout>
</LinearLayout>
<LinearLayout 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:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp">
</android.support.v7.widget.RecyclerView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:layout_gravity="bottom"
android:layout_alignParentBottom="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
/>
</RelativeLayout>
</RelativeLayout>
</FrameLayout>
有改一下你的布局尝试这将解决您的问题。
<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="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_below="@+id/toolbar"
android:layout_above="@+id/footer"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<RelativeLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="#ff6b6b"
android:layout_alignParentBottom="true">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@mipmap/ic_launcher" />
</RelativeLayout>
使用以下来实现自己的目标..
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
>
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
</FrameLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_alignParentBottom="true"
android:background="#ff6b6b"
android:gravity="bottom">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:background="#ff6b6b">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@drawable/ic_log_arrow" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
请更换您的代码
<LinearLayout 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:orientation="vertical"
tools:context="abtech.waiteriano.com.waitrer.MenuActivity">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize" />
<!-- A RecyclerView with some commonly used attributes -->
<FrameLayout
android:id="@+id/content_frame"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"></FrameLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="60dp"
android:background="#ff6b6b">
<ImageView
android:id="@+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:src="@drawable/fire" />
</RelativeLayout>
</LinearLayout>
有一个recyclerview你想在底部的相对布局和顶部的工具栏之间。 或 Recyclerview + framelayout两者都有? –
@Deep Patel感谢您的兴趣我只是想这个相对布局显示在线性布局的底部关于工具栏它应该在顶部我只是想在这个相对布局中放置一个按钮或相对布局在这个相关布局 –