Replace fragment inside fragment :Exception No view found for id 0x - java

I have one fragment and I try to replace some another fragment in my layout.Here is a fragment replace code
public static void replace(FragmentManager fm, Fragment fragment, int container, String tag) {
FragmentTransaction fragmentTransaction = fm.beginTransaction();
fragmentTransaction.replace(container, fragment, tag);
fragmentTransaction.commit();
}
Here is a main code
if (cardList != null && cardList.isEmpty()) {
hideDialog(pDialog);
drawavleView.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
norecordfragment = new NoRecordFragment();
norecordfragment.setAvatar(R.drawable.ic_card_nocard);
norecordfragment.setText(getActivity().getString(R.string.u_cards_no_data_text));
norecordfragment.setButtontext(getActivity().getString(R.string.u_cards_no_data_action));
norecordfragment.setAllowToShowAddAction(false);
floatingActionButton.setVisibility(View.VISIBLE);
FragmentUtils.replace(getActivity().getSupportFragmentManager(), norecordfragment,
R.id.upload_main_layout_upload,"norecordfragment");
}
Here is my xml code
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:fitsSystemWindows="false">
<ScrollView 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:fillViewport="true"
android:minHeight="#dimen/u_base_min_height">
<RelativeLayout
android:id="#+id/upload_main_layout_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay_v3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/upload_header_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/transfer_headerView_height"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#f2f2f2" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/u_common_margin_left"
android:layout_marginRight="#dimen/u_common_margin_left"
android:layout_marginTop="#dimen/withdrow_change_card_height"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/u_widget_height"
android:background="#drawable/edittext_input_background_not_focus"
android:orientation="horizontal">
<EditText
android:id="#+id/u_major_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="7dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.65"
android:background="#null"
android:gravity="left"
android:hint="0.00"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxLines="1"
android:singleLine="true"
android:textColor="#4d4d4d"
android:textColorHint="#b2b2b2"
android:textSize="35dp" />
<Spinner
android:id="#+id/upload_spinner"
style="#style/Widget.MyApp.HeaderBar.Spinner"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/edittext_input_background_not_focus" />
<ImageView
android:id="#+id/u_open_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/transfer_user_description"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:padding="#dimen/slide_menu_hide_image"
android:src="#drawable/ic_menu_downarrow_grey" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/lay_v4"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
android:paddingLeft="#dimen/u_common_margin_left"
android:paddingRight="#dimen/u_common_margin_left">
<com.ripperLayout.MaterialRippleLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="#dimen/u_widget_height"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical"
app:mrl_rippleAlpha="0.2"
app:mrl_rippleColor="#ffffff"
app:mrl_rippleDelayClick="false"
app:mrl_rippleHover="true"
app:mrl_rippleOverlay="true"
app:mrl_rippleRoundedCorners="4dp">
<Button
android:id="#+id/u_done"
android:layout_width="fill_parent"
android:layout_height="#dimen/u_widget_height"
android:background="#drawable/rounded_corners_blue"
android:text="#string/u_register_next"
android:textColor="#ffffff"
android:textSize="#dimen/u_common_text_size_small" />
</com.ripperLayout.MaterialRippleLayout>
<View
android:layout_width="match_parent"
android:layout_height="#dimen/u_common_margin_left"
android:visibility="invisible" />
</LinearLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:id="#+id/floating_action_bar_transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4D000000"
android:clickable="true"
android:orientation="vertical"
android:visibility="gone" />
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/floating_action_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_add_white"
app:backgroundTint="#48c9ff" />
</android.support.design.widget.CoordinatorLayout>
I don't know why in some devices I have this exception.
Exception java.lang.IllegalArgumentException: No view found for id 0x7f09052f (com.me.myapp:id/upload_main_layout_upload) for fragment NoRecordFragment{5309279 #4 id=0x7f09052f norecordfragment}
As you can see, I tried to replace my custom fragment inside upload_main_layout_upload layout, but I have this exception. What am I doing wrong? Thanks.

To implement a Fragment inside another layout, you need to have the layout that you are showing inside the Fragment in another fragment_layout.xml file. So you need to modify your current layout as follows.
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:fitsSystemWindows="false">
<ScrollView 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:fillViewport="true"
android:minHeight="#dimen/u_base_min_height">
<RelativeLayout
android:id="#+id/upload_main_layout_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"/>
</ScrollView>
<LinearLayout
android:id="#+id/floating_action_bar_transparent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#4D000000"
android:clickable="true"
android:orientation="vertical"
android:visibility="gone" />
<android.support.design.widget.FloatingActionButton xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/floating_action_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_add_white"
app:backgroundTint="#48c9ff" />
</android.support.design.widget.CoordinatorLayout>
And take the content inside the RelativeLayout outside of this layout and create another layout which will be used in your Fragment to get views from there.
Here's a sample fragment_layout.xml.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/lay_v3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/upload_header_layout"
android:layout_width="match_parent"
android:layout_height="#dimen/transfer_headerView_height"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#f2f2f2" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/u_common_margin_left"
android:layout_marginRight="#dimen/u_common_margin_left"
android:layout_marginTop="#dimen/withdrow_change_card_height"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/u_widget_height"
android:background="#drawable/edittext_input_background_not_focus"
android:orientation="horizontal">
<EditText
android:id="#+id/u_major_text"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginBottom="7dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.65"
android:background="#null"
android:gravity="left"
android:hint="0.00"
android:imeOptions="actionDone"
android:inputType="numberDecimal"
android:maxLines="1"
android:singleLine="true"
android:textColor="#4d4d4d"
android:textColorHint="#b2b2b2"
android:textSize="35dp" />
<Spinner
android:id="#+id/upload_spinner"
style="#style/Widget.MyApp.HeaderBar.Spinner"
android:layout_width="80dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:background="#drawable/edittext_input_background_not_focus" />
<ImageView
android:id="#+id/u_open_spinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/transfer_user_description"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_gravity="center"
android:padding="#dimen/slide_menu_hide_image"
android:src="#drawable/ic_menu_downarrow_grey" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
You have too many nested layouts inside one as far as I can see. You need to rearrange your layouts as per your requirement and transaction flows between Activity and Fragments.

Related

In my layout there is recyclerview and bottom navigation bar but navigation bar goes behinf the recycler view

In my layout there is recyclerview and bottom navigation bar but the problem is that the recyclerview occupies all the view and the bottom navigation bar and the header bad goes behind the recycler view. I've sucessfully implemented the material dependency.
this is the layout:
This is the code of the layout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="#+id/baseLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!--status bar-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/default_activity_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:backgroundTint="#color/buttoncolor"
app:menu="#menu/default_menu" />
<!--add button-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:backgroundTint="#color/buttoncolor"
app:fabAlignmentMode="end"
app:fabCradleMargin="6.2sp"
app:fabCradleRoundedCornerRadius="15sp"
app:menu="#menu/app_bar_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#ED4444"
android:onClick="openCamera"
android:src="#drawable/ic_add"
app:layout_anchor="#id/bottomAppBar"
app:maxImageSize="35sp"
app:tint="#color/white" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/empty_list" />
<LinearLayout
android:id="#+id/empty_list"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/empty_list_icon"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/ic_no_data" />
<TextView
android:id="#+id/empty_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Scan the files"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="24dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/empty_list_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan to make something great"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Try this by giving specific height to the BottomAppBar. Then provide margin top and Bottom to the RelativeLayout :
<?xml version="1.0" encoding="utf-8"?>
<androidx.coordinatorlayout.widget.CoordinatorLayout 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:id="#+id/baseLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<!--status bar-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/default_activity_button"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="top"
android:backgroundTint="#color/buttoncolor"
app:menu="#menu/default_menu" />
<!--add button-->
<com.google.android.material.bottomappbar.BottomAppBar
android:id="#+id/bottomAppBar"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:backgroundTint="#color/buttoncolor"
app:fabAlignmentMode="end"
app:fabCradleMargin="6.2sp"
app:fabCradleRoundedCornerRadius="15sp"
app:menu="#menu/app_bar_menu" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:backgroundTint="#ED4444"
android:onClick="openCamera"
android:src="#drawable/ic_add"
app:layout_anchor="#id/bottomAppBar"
app:maxImageSize="35sp"
app:tint="#color/white" />
<RelativeLayout
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/rw"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/empty_list" />
<LinearLayout
android:id="#+id/empty_list"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical">
<ImageView
android:id="#+id/empty_list_icon"
android:layout_width="200dp"
android:layout_height="200dp"
android:background="#drawable/ic_no_data" />
<TextView
android:id="#+id/empty_list_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="Scan the files"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:textSize="24dp"
android:gravity="center_horizontal"/>
<TextView
android:id="#+id/empty_list_message"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Scan to make something great"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:gravity="center_horizontal" />
</LinearLayout>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>

ScrollView top part is cut off when I added adjustPan so keyboard won't overlap EditText

I have a ScrollView (with a RecyclerView inside) and a RelativeLayout after it which contains EditText. I added
android:windowSoftInputMode="stateAlwaysHidden|adjustPan"
for the activity in my manifest file because my keyboard overlaps the EditText but in effect, whenever the keyboard is active, the top part of my ScrollView is cut off.
I have tried using NestedScrollView and setting RelativeLayout android:layout_height="wrap_content" and android:layout_gravity="center" but that doesn't work. Below is the snippet of my code:
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adView"
android:layout_alignParentTop="true"
android:background="#android:color/white"
android:scrollbars="vertical">
<RelativeLayout
...
</RelativeLayout>
<ScrollView
android:id="#+id/news_comments"
android:fillViewport="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rl_title">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/individual_news_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="5dp"
android:orientation="vertical">
// some other layouts
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/individual_news_item"
android:orientation="vertical"
android:paddingEnd="15dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingStart="15dp"
android:paddingTop="15dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="15dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<RelativeLayout
android:id="#+id/ll_message_actions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:id="#+id/ll_send_message"
android:layout_width="match_parent"
android:background="#android:color/white"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_alignParentBottom="true">
<github.ankushsachdeva.emojicon.EmojiconEditText
android:id="#+id/et_message_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:focusable="true"
android:focusableInTouchMode="true"
android:hint="#string/keyMessage"
android:inputType="textMultiLine|textNoSuggestions"
android:background="#android:color/transparent"
android:maxLines="4"
android:paddingBottom="5dp"
android:paddingEnd="0dp"
android:paddingLeft="20dp"
android:paddingRight="0dp"
android:paddingStart="20dp"
android:paddingTop="5dp"
android:textColor="#color/light_black"
android:textColorHint="#color/zipt"
android:textSize="17sp"
emojicon:emojiconSize="18sp" />
<ImageButton />
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
any ideas how i can solve this?

How to add spacing between each Item in list view

I just created a simple custom list view and I want to add spacing between each item in list View I already added vertical spacing attribute but there's no spacing yet this is my xml file for list view
<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="abtech.waiteriano.com.waitrer.fragments.LVMenuFragment">
<!-- TODO: Update blank fragment layout -->
<ListView
android:id="#+id/listView"
android:layout_width="fill_parent"
android:verticalSpacing="20dp"
android:layout_height="fill_parent" >
</ListView>
</FrameLayout>
and this is listitem.xml
<?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">
<RelativeLayout
android:id="#+id/menuRL"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:background="#drawable/listviewborder">
<ImageView
android:id="#+id/itemImage"
android:layout_width="65dp"
android:layout_height="fill_parent"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:srcCompat="#drawable/icic" />
<TextView
android:id="#+id/menulistTV2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toEndOf="#+id/itemImage"
android:text="TextView"
android:textSize="16dp"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/qtyID"
android:layout_width="75dp"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_toStartOf="#+id/minusBtn"
android:background="#drawable/qty_border">
<TextView
android:id="#+id/txtQTY"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="0"
android:textSize="30dp" />
</RelativeLayout>
<Button
android:id="#+id/minusBtn"
android:layout_width="50dp"
android:layout_height="fill_parent"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:background="#drawable/minus_borders"
android:text="-"
android:textSize="40dp" />
</RelativeLayout>
</LinearLayout>
Just use:
android:divider="#android:color/transparent"
android:dividerHeight="20dp"
in ListView
<ListView
android:id="#+id/listView"
android:layout_width="fill_parent"
android:marigin_bottom="5dp";
android:verticalSpacing="20dp"
android:layout_height="fill_parent" >
</ListView>
Find the solution
In listitem add margin
<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:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<TextView/>
<TextView/>
</LinearLayout>
For First and Last Item add margin in Listview
<Listview
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
/>

Linear layout overlapping another linear layout

I have two LinearLayouts in a RelativeLayout the problem is that the top linear layout is overlapping the bottom one a little bit.I tried everything. Please Somebody help me.Below is my XML File
Or tell me how to do it programmatically. Like subtracting height of one linear layout from another.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<FrameLayout
android:id="#+id/page_fragment"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#color/spinner_text_color" />
<FrameLayout
android:id="#+id/detail_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white_bg"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/spinner_text_color">
<Button
android:id="#+id/filterResetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textColor="#color/white_bg"
android:textAllCaps="false"
android:background="#drawable/light_button_click"
android:text="Reset All" />
<Button
android:id="#+id/filterApplyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textAllCaps="false"
android:background="#drawable/submit_order_click"
android:textColor="#color/white_bg"
android:text="Apply" />
</LinearLayout>
</RelativeLayout>
Try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1"
android:layout_above="#+id/linearLayout">
<FrameLayout
android:id="#+id/page_fragment"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#color/colorPrimary" />
<FrameLayout
android:id="#+id/detail_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/colorPrimary"
android:id="#+id/linearLayout">
<Button
android:id="#+id/filterResetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textColor="#color/white"
android:textAllCaps="false"
android:background="#drawable/ic_authy"
android:text="Reset All" />
<Button
android:id="#+id/filterApplyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textAllCaps="false"
android:background="#drawable/ic_arrow_32"
android:textColor="#color/white"
android:text="Apply" />
</LinearLayout>
</RelativeLayout>
Use Relative Layout properties like
layout_below and layout_above
Try following code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/bottomLayout"
android:orientation="horizontal"
android:weightSum="1">
<FrameLayout
android:id="#+id/page_fragment"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#color/spinner_text_color" />
<FrameLayout
android:id="#+id/detail_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white_bg"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/spinner_text_color">
<Button
android:id="#+id/filterResetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textColor="#color/white_bg"
android:textAllCaps="false"
android:background="#drawable/light_button_click"
android:text="Reset All" />
<Button
android:id="#+id/filterApplyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textAllCaps="false"
android:background="#drawable/submit_order_click"
android:textColor="#color/white_bg"
android:text="Apply" />
</LinearLayout>
</RelativeLayout>
If the layouts are large and can't be accommodated in a single a screen then you should wrap both the linear layouts in a scrollView. Let me know if you face problem in using scrollView.
This is very easy you just have to set id to the Linear Layout at bottom like
**android:id="#+id/bottom_linearlayout"**
and set the upper Linear Layout "above" over the bottom ones "id", like this
**android:layout_above="#id/bottom_linearlayout"**
`<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_above="#id/bottom_linearlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1">
<FrameLayout
android:id="#+id/page_fragment"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#color/spinner_text_color" />
<FrameLayout
android:id="#+id/detail_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white_bg"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/bottom_linearlayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/spinner_text_color">
<Button
android:id="#+id/filterResetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textColor="#color/white_bg"
android:textAllCaps="false"
android:text="Reset All" />
<Button
android:id="#+id/filterApplyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textAllCaps="false"
android:textColor="#color/white_bg"
android:text="Apply" />
</LinearLayout>
</RelativeLayout>`
you parent layout is linear layout so child is overlap each other
use my code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="1"
android:layout_weight="90">
<FrameLayout
android:id="#+id/page_fragment"
android:layout_width="150dp"
android:layout_height="match_parent"
android:background="#color/spinner_text_color" />
<FrameLayout
android:id="#+id/detail_fragment"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#color/white_bg"
android:layout_weight="1"></FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="10"
android:layout_alignParentBottom="true"
android:background="#color/spinner_text_color">
<Button
android:id="#+id/filterResetButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textColor="#color/white_bg"
android:textAllCaps="false"
android:background="#drawable/light_button_click"
android:text="Reset All" />
<Button
android:id="#+id/filterApplyButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".50"
android:textAllCaps="false"
android:background="#drawable/submit_order_click"
android:textColor="#color/white_bg"
android:text="Apply" />
</LinearLayout>
</LinearLayout>

Floating Action Button between two tabs

I have a fab and would like to have it during the passage between two tabs, tried to put the transparent background in fragment_main.xml but without success. The problem is really how do I put the background of the two fragments appearing while allowing this gray stripe cutting because of FAB. Very grateful to those who help me.
fragment_main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000"
android:orientation="vertical">
<br.com.test.common.view.SlidingTabLayout
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="0px"
android:layout_weight="1"
android:background="#0000"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/pink_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_icon="#drawable/ic_add"
fab:fab_colorNormal="#color/material_orange_500"
fab:fab_colorPressed="#color/material_orange_a200"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom|right"
android:layout_marginBottom="16dp"/>
</LinearLayout>
fragment_profile.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="?android:attr/colorBackground"
android:layout_weight="1"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<ImageView
android:id="#+id/profileImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_launcher"
android:padding="10dp"
android:scaleType="centerInside"/>
<TextView
android:id="#+id/profileName"
android:layout_below="#id/profileImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="teste"
android:textSize="22sp"/>
<LinearLayout
android:id="#+id/ll_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/profileName"
android:padding="10dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="150dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="#+id/info_text"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="teste"/>
</android.support.v7.widget.CardView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/ll_1"
android:padding="10dp">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/card_view_2"
android:layout_gravity="center"
android:layout_width="fill_parent"
android:layout_height="150dp"
card_view:cardCornerRadius="4dp">
<TextView
android:id="#+id/info_text2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="teste"/>
</android.support.v7.widget.CardView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
fragment_service.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:gravity="center_vertical">
<TableRow>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/imgDP"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo_dp"/>
<TextView
android:layout_below="#id/imgDP"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DP"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp">
<ImageView
android:id="#+id/imgNA1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:src="#drawable/logo_na"/>
<TextView
android:layout_below="#id/imgNA"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NA"/>
</RelativeLayout>
</TableRow>
</TableLayout>
</LinearLayout>
Eihschnaehkeee is right -- you just need a layout that allows overlapping. Here is XML to try (also adding right margin for your button):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:fab="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0000">
<br.com.test.common.view.SlidingTabLayout
android:id="#+id/sliding_tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<android.support.v4.view.ViewPager
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/sliding_tabs"
android:layout_alignParentBottom="true"
android:background="#0000"/>
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/pink_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
fab:fab_icon="#drawable/ic_add"
fab:fab_colorNormal="#color/material_orange_500"
fab:fab_colorPressed="#color/material_orange_a200"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginBottom="16dp"
android:layout_marginRight="16dp"/>
</RelativeLayout >
Eihschnaehkeee and Bruce.
I tried to put as relative layout and swipe funcinou not more, I tried using SlidingTabLayout the android code https://github.com/googlesamples/android-SlidingTabsBasic/

Categories