简体   繁体   中英

there is no android:layout_below in android studio

I'm trying to put a recyclerview below my LinearLayout but there was no android:layout_below option for the recyclerview! then i tried to put my recyclerview into a LinearLayout and set layout_below for the layout but there was no layout_below for linearlayout either!

I'm sorry i'm not good at english but anyway ... here is my XML:

<FrameLayout 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"
    tools:context="tablo.mirshekari.customers.StoreFragment">

<LinearLayout
    android:id="@+id/store_view"
    android:layout_width="match_parent"
    android:layout_height="200dp"
    android:gravity="right"
    android:paddingRight="20dp"
    android:paddingTop="20dp"
    android:background="@color/cardview_dark_background"
    android:orientation="vertical">
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="45dp"
        android:gravity="right"
        android:paddingTop="10dp"
        android:background="@color/cardview_dark_background"
        android:orientation="horizontal">
    <TextView
        android:layout_width="match_parent"
        android:layout_height="30dp"
        android:text="lasjdbkajbd"
        android:textColor="@color/white"
        android:paddingRight="10dp"
        android:layout_gravity="right"
        android:gravity="right|center_vertical"
        android:id="@+id/store_name" />
    <ImageView
        android:layout_width="30dp"
        android:layout_height="30dp"
        android:src="@drawable/ic2w"
        android:layout_gravity="right"
        />

</LinearLayout>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="60dp"
        android:gravity="right"
        android:background="@color/cardview_dark_background"
        android:orientation="horizontal">
        <TextView
            android:layout_width="match_parent"
            android:layout_height="30dp"
            android:text="lasjdbkajbd"
            android:textColor="@color/white"
            android:paddingRight="10dp"
            android:layout_gravity="right"
            android:gravity="right|center_vertical"
            android:id="@+id/store_textposition" />
        <ImageView
            android:layout_width="30dp"
            android:layout_height="30dp"
            android:src="@drawable/address_white"
            android:layout_gravity="right"
            />

    </LinearLayout>

</LinearLayout>

<android.support.v7.widget.RecyclerView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ></android.support.v7.widget.RecyclerView>
</FrameLayout>

As far as I know, layout_below is only available for RelativeLayout . See RelativeLayout.LayoutParams and LinearLayout.LayoutParams .

This means, you must put your views into RelativeLayout to use that attribute.

UPDATE

Yep, you are putting your views to a FrameLayout . Consider changing it to LinearLayout with vertical orientation or using RelativeLayout with layout_below for the RecyclerView .

Linear layout does not contain android: layout_below option. So, you can use relative layout in place of linear layout to use android:layout_below option .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM