Reputation: 43
Please help. how i can convert this code from LinearLayout to Relative Layout, if its possible. Or what i can do to work this code with FAB in overlay?
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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"
tools:context=".MainActivity"
android:orientation="vertical"
android:background="@color/white">
<android.support.v7.widget.Toolbar
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:minHeight="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light" />
<!-- Framelayout to display Fragments -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/emptyScreen">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="@string/label_empty_list"
android:id="@+id/emptyScreenMsg"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:textColor="@color/gray_text" />
</RelativeLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/contentScreen" >
<android.support.v4.widget.SwipeRefreshLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/itemsContainer"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_width="match_parent"
android:background="@color/white">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:id="@+id/streamListView" />
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="50dp"
android:visibility="gone"
android:background="@color/white"
android:gravity="center"
android:id="@+id/streamAdMobCont">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id">
</com.google.android.gms.ads.AdView>
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/loadingScreen"
android:background="@color/white">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/progressBar"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/errorScreen"
android:background="@color/white">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="20dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/error_data_loading"
android:id="@+id/StreamErrorScreenMsg"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:gravity="center"
android:textSize="16dp"
android:textColor="@color/gray_text" />
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="@color/drawer_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/item_list_row_selector"
android:background="@color/drawer_bg"
android:scrollbars="none"
android:padding="0dp" />
Plaeeaaseeeeeeee help me pleaseeeeeeeeee... Thank's and sorry for my bad english :)
Upvotes: 0
Views: 1302
Reputation: 676
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<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:background="@color/white"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.v7.widget.Toolbar xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:minHeight="?attr/actionBarSize"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" />
<!-- Framelayout to display Fragments -->
<RelativeLayout
android:id="@+id/emptyScreen"
android:layout_below="@id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/emptyScreenMsg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/label_empty_list"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@color/gray_text" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/contentScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/emptyScreen"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/itemsContainer"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="@color/white">
<ListView
android:id="@+id/streamListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none" />
</android.support.v4.widget.SwipeRefreshLayout>
<LinearLayout
android:id="@+id/streamAdMobCont"
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@color/white"
android:gravity="center"
android:layout_below="@id/itemsContainer"
android:orientation="vertical"
android:visibility="gone">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
ads:adSize="BANNER"
ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="@+id/loadingScreen"
android:layout_below="@id/contentScreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<ProgressBar
android:id="@+id/progressBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/errorScreen"
android:layout_below="@id/loadingScreen"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@color/white">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:orientation="vertical"
android:padding="20dp">
<TextView
android:id="@+id/StreamErrorScreenMsg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:gravity="center"
android:text="@string/error_data_loading"
android:textColor="@color/gray_text"
android:textSize="16dp" />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="300dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/drawer_bg"
android:choiceMode="singleChoice"
android:divider="@color/drawer_divider"
android:dividerHeight="1dp"
android:listSelector="@drawable/item_list_row_selector"
android:padding="0dp"
android:scrollbars="none" />
</android.support.v4.widget.DrawerLayout>
Upvotes: 1
Reputation: 5609
Just use android:layoutBelow for each item.
Android's documentation has a good example.
Upvotes: 0