Android Floating buttons are not set at a fixed position - android

I am showing the 2 floating buttons in my activity but the floating buttons are setting at bottom end when there is no data to show in the activity. if records are show in the activity then the floating buttons are showing after the records instead of at a fix position
Following is my activity layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/login_background"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:background="#color/login_header"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imgInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:src="#drawable/info" />
<ImageView
android:id="#+id/imgLogout"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginStart="290dp"
android:src="#drawable/logout" />
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginTop="10dp"
android:src="#drawable/logo1" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingStart="120dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center_horizontal|center_vertical"
android:background="#color/login_header"
android:src="#drawable/userprofile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/segoeui"
android:paddingStart="20dp"
android:text="#string/name"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/machineLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/search"
android:layout_width="46dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#drawable/search" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/addNew"
android:layout_width="46dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#drawable/add" />
Following the screen shot

Try this
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:id="#+id/imgInfo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:src="#drawable/ic_message" />
<ImageView
android:id="#+id/imgLogout"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_marginStart="290dp"
android:src="#drawable/ic_message" />
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginTop="10dp"
android:src="#drawable/kid_goku" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
android:paddingStart="120dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_gravity="center_horizontal|center_vertical"
android:src="#drawable/kid_goku" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:paddingStart="20dp"
android:text="name"
android:textColor="#color/white"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/machineLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical">
</android.support.v7.widget.RecyclerView>
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/search"
android:layout_width="46dp"
android:layout_height="wrap_content"
android:layout_above="#+id/addNew"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#drawable/ic_message" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/addNew"
android:layout_width="46dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#drawable/ic_message" />
</RelativeLayout>
OUTPUT

Use CoordinatorLayout as root view.
And Also add app:layout_anchorGravity="bottom|right|end(specify as you need)" in FloatingActionButton

Related

How to scroll an EditText to the very top of the layout?

So I have this layout with some ChipsInput inside a scrollview and I simply want these to go to the very top when the keyboard is activated
I've tried to change windowSoftInputMode to adjustPan and others but it does not make it to go to the very top, just doesn't cover it.
Here's my xml layout
<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:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background1"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<LinearLayout
android:id="#+id/layoutImage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:background="#color/colorPrimary"
android:elevation="12dp"
android:orientation="horizontal"
android:padding="10dp"
tools:targetApi="lollipop">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_margin="3dp"
android:layout_weight="1"
android:fontFamily="#font/quattrocento"
android:gravity="left"
android:text="#string/profile"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#color/textColor1"
tools:ignore="RtlHardcoded" />
<ImageButton
android:id="#+id/btUpdate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"
android:background="#color/colorPrimary"
android:src="#drawable/arrow_right_icon" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="5dp"
android:orientation="vertical"
tools:targetApi="o">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:fontFamily="#font/quattrocento"
android:gravity="center"
android:text="#string/gallery"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#color/textColor2"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:orientation="horizontal"
android:padding="5dp"
android:baselineAligned="false">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/close1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_close"
android:background="#color/white"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"
android:visibility="invisible"/>
<ImageButton
android:id="#+id/add1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_add"
android:background="#color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"/>
<ImageView
android:id="#+id/photo1"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginHorizontal="5dp"
android:background="#drawable/rounded_rect_primary_dark"
android:elevation="5dp"
android:scaleType="fitXY"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/close2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_close"
android:background="#color/white"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"
android:visibility="invisible"/>
<ImageButton
android:id="#+id/add2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_add"
android:background="#color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"/>
<ImageView
android:id="#+id/photo2"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginHorizontal="5dp"
android:background="#drawable/rounded_rect_primary_dark"
android:elevation="5dp"
android:scaleType="fitXY" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1">
<ImageButton
android:id="#+id/close3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_close"
android:background="#color/white"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"
android:visibility="invisible"/>
<ImageButton
android:id="#+id/add3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_add"
android:background="#color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:elevation="7dp"/>
<ImageView
android:id="#+id/photo3"
android:layout_width="match_parent"
android:layout_height="115dp"
android:layout_marginHorizontal="5dp"
android:background="#drawable/rounded_rect_primary_dark"
android:elevation="5dp"
android:scaleType="fitXY"/>
</RelativeLayout>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginHorizontal="12dp"
android:layout_marginVertical="5dp"
android:background="#color/black" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/quattrocento"
android:text="#string/about_me"
android:textColor="#color/textColor2"
android:textSize="20sp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/white">
<EditText
android:id="#+id/description"
android:layout_width="match_parent"
android:layout_height="70dp"
android:background="#color/white"
android:focusable="true"
android:maxLength="500"
android:inputType="text"
android:importantForAutofill="no"
android:autofillHints="no"
tools:ignore="LabelFor" />
<TextView
android:id="#+id/caracCounter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/quattrocento"
android:text="500"
android:textColor="#color/black"
android:textSize="16sp"
android:layout_gravity="end" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/quattrocento"
android:text="#string/interest1"
android:textColor="#color/textColor2"
android:textSize="20sp"
android:layout_gravity="center"
android:gravity="center"/>
<Spinner
android:id="#+id/categories1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:background="#color/colorPrimary" />
</LinearLayout>
<com.pchmn.materialchips.ChipsInput
android:id="#+id/chipsInput1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/white"
android:elevation="3dp"
android:focusable="false"
app:chip_deletable="true"
app:chip_hasAvatarIcon="false"
app:hint="#"
app:chip_backgroundColor="#color/colorPrimary"
app:chip_deleteIconColor="#color/black"
app:chip_labelColor="#color/black"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center"
android:gravity="center"
android:layout_marginLeft="10dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/quattrocento"
android:text="#string/interest2"
android:textColor="#color/textColor2"
android:textSize="20sp"
android:layout_gravity="center"
android:gravity="center"/>
<Spinner
android:id="#+id/categories2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:background="#color/colorPrimary" />
</LinearLayout>
<com.pchmn.materialchips.ChipsInput
android:id="#+id/chipsInput2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:background="#color/white"
android:elevation="3dp"
android:focusable="false"
app:chip_deletable="true"
app:chip_hasAvatarIcon="false"
app:hint="#"
app:chip_backgroundColor="#color/colorPrimary"
app:chip_deleteIconColor="#color/black"
app:chip_labelColor="#color/black" />
<Button
android:id="#+id/btLogout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_margin="25dp"
android:background="#color/colorPrimary"
android:elevation="12dp"
android:fontFamily="#font/quattrocento"
android:text="#string/logout"
android:textSize="20sp"
android:onClick="logout"
tools:targetApi="lollipop"
android:textColor="#color/black"/>
</LinearLayout>
</ScrollView>
I simply need it to be sent to the very top of the layout so my filterable list will appear when the user start to type.
You can use CoordinatorLayout as your root and NestedScrolView in it .
CoordinatorLayout as root reacts to keyboard and scrolls your layout to the top of your phone with assistant of NestedScrollView which your NestedScrollView includes your layout code .
To put the issue into perspective view
CoordinaterLayout > NestedScrolView > yourLayout
Change your layout XMl like code below
<android.support.design.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:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/constraintLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background1"
android:focusable="true"
android:focusableInTouchMode="true"
android:orientation="vertical">
<!-- rest of your layout xml code-->
</android.support.v4.widget.NestedScrollView>
</android.support.design.widget.CoordinatorLayout>

Scroll view with Relative layout

I am building a layout with scroll view and inside the scroll view, there is a relative layout. I want to place the FloatingActionButton on the bottom center of the layout, but I don't know what is happening.
This is my layout:
Here's my code below:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
tools:context="com.example.mani.fakecall.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="16dp">
<ImageButton
android:id="#+id/display_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/circular_image_button"
android:src="#drawable/ic_add_white_24dp" />
<EditText
android:id="#+id/display_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="#string/enter_number"
android:inputType="number" />
<EditText
android:id="#+id/display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="#string/enter_name"
android:inputType="textCapWords" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:elevation="8dp"
android:text="#string/set_time" />
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:clickable="true"
android:elevation="12dp"
android:src="#drawable/ic_call_white_24dp"
app:backgroundTint="#color/colorFab"
app:elevation="0dp" />
</RelativeLayout>
</ScrollView>
Your hierarchy will be like this
<RelativeLayout 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"
tools:context="com.example.mani.fakecall.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<ImageButton
android:id="#+id/display_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:background="#drawable/circular_image_button"
android:src="#drawable/ic_add_white_24dp" />
<EditText
android:id="#+id/display_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="#string/enter_number"
android:inputType="number" />
<EditText
android:id="#+id/display_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:hint="#string/enter_name"
android:inputType="textCapWords" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:elevation="8dp"
android:text="#string/set_time" />
</LinearLayout>
</ScrollView>
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_margin="16dp"
android:clickable="true"
android:elevation="12dp"
android:src="#drawable/ic_add"
app:backgroundTint="#color/colorAccent"
app:elevation="0dp" />
</RelativeLayout>
edited

How to fit the tab above of the screen when scrolling the page?

I want to design the screen. layout, tab and grid view I want to scroll option. In scroll time, fix the tab on the header (Below of status bar) and grid view scroll to end of grid view content. In the bottom, I fixed bottom navigation bar.
This is my xml code:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
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:background="#color/layout_background"
android:fillViewport="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/rlay_home_page_Tap"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/rlay_home_page_Tap1"
android:background="#color/layout_background">
<RelativeLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="185dp"
android:background="#drawable/main_header_selector"
android:gravity="bottom|center">
<ImageView
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/llay_home_bottom2"
android:layout_marginStart="12dp"
android:layout_marginTop="12dp"
android:layout_toEndOf="#+id/llay_home_bottom2" />
<TextView
android:id="#+id/textView10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/profile_image"
android:layout_marginTop="10dp"
android:layout_toEndOf="#+id/img_fb_dp"
android:layout_weight="1"
android:gravity="center"
android:text=""
android:textColor="#000"
android:textSize="16dp" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:layout_marginTop="24dp"
android:src="#drawable/ic_profile" />
<TextView
android:id="#+id/amsc_txt_home_fbusername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/textView10"
android:gravity="center"
android:textColor="#fff"
android:textSize="16dp" />
<TextView
android:id="#+id/amsc_txt_home_All_ImgCount"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_above="#+id/textView10"
android:layout_marginBottom="60dp"
android:layout_marginStart="20dp"
android:gravity="center"
android:text="125 \nPhotos"
android:textColor="#fff"
android:textSize="12dp" />
<TextView
android:id="#+id/amsc_txt_home_Fav_ImgCount"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_above="#+id/textView10"
android:layout_alignParentEnd="true"
android:layout_marginBottom="60dp"
android:layout_marginEnd="20dp"
android:gravity="center"
android:text="125 \nFavouite"
android:textColor="#fff"
android:textSize="12dp" />
</RelativeLayout>
<android.support.design.widget.TabLayout
android:id="#+id/simpleTabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout"
android:gravity="center"
app:tabGravity="fill"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/tab_select_color"
app:tabTextColor="#color/black_text_color" />
<RelativeLayout
android:id="#+id/llay_home_grd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/simpleTabLayout"
android:layout_above="#+id/linearLayout8"
android:background="#color/layout_background"
android:orientation="vertical">
<GridView
android:id="#+id/grid_test1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="2dp"
android:layout_marginStart="2dp"
android:background="#color/layout_background"
android:horizontalSpacing="2dp"
android:numColumns="3"
android:verticalSpacing="2dp" />
>
</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/linearLayout8"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:background="#android:color/white"
android:orientation="horizontal">
<LinearLayout
android:id="#+id/linearLayout6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:background="#android:color/white"
android:orientation="horizontal">
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_navigation_home1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:background="#color/wight"
app:itemIconTint="#drawable/bottom_navigation_color_selector"
app:itemTextColor="#drawable/bottom_navigation_color_selector"
app:menu="#menu/my_navigation_home" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentStart="true"
android:background="#android:color/white"
android:orientation="horizontal"
android:visibility="gone">
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_navigation_home2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:background="#color/wight"
app:itemIconTint="#drawable/bottom_navigation_color_selector2"
app:itemTextColor="#drawable/bottom_navigation_color_selector2"
app:menu="#menu/my_navigation_home2" />
</LinearLayout>
</RelativeLayout>
<ImageView
android:id="#+id/img_take_cam_but"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="20dp"
android:onClick=""
android:background="#drawable/ic_capture"/>
</RelativeLayout>
</FrameLayout>
Above code , gridview only scrolling.How to scroll image type.
use appbarlayout and drawer layout for doing the tab part
<android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.AppBarLayout>
<android.support.v7.widget.Toolbar/>
<android.support.design.widget.TabLayout/>
</android.support.design.widget.AppBarLayout>
<!---your--layout--here--->
</android.support.design.widget.CoordinatorLayout>

Recyclerview disappear

I am using below xml code with adjustresize option with activity to resize it but my recyclerview disappear after resize.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/content_add_document"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.labs108.teddy.activities.AddListActivity"
tools:showIn="#layout/activity_add_list">
<android.support.v7.widget.CardView
android:id="#+id/card_layout"
android:layout_width="match_parent"
android:layout_height="320dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:id="#+id/title"
android:layout_marginLeft="16dp"
android:hint="Title"
android:background="#null"
android:layout_width="match_parent"
android:layout_height="52dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#drawable/img_divider" />
<ScrollView
android:layout_width="match_parent"
android:scrollbars="vertical"
android:layout_marginBottom="40dp"
android:layout_height="262dp">
<com.github.irshulx.Editor
android:id="#+id/description"
android:gravity="top"
app:render_type="Editor"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingBottom="100dp"
app:placeholder="Start writing here..."
android:layout_width="match_parent"
android:layout_height="match_parent" />
</ScrollView>
<View
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#drawable/img_divider" />
</LinearLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:id="#+id/documentlayout"
android:layout_below="#+id/card_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/document_image"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</android.support.v7.widget.RecyclerView>
<RelativeLayout
android:id="#+id/rl_add_info_bottom"
android:layout_width="328dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginTop="16dp"
android:layout_below="#+id/document_image"
android:background="#drawable/button_white_gradient"
android:minHeight="#dimen/min_btn_height">
<TextView
android:id="#+id/tv_invite_more_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="#dimen/eight_dp"
android:text="Add Photo"
android:textColor="#4ED9CA"
android:textAppearance="#style/TextAppearance.SFSemibold"
android:textSize="14sp" />
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toLeftOf="#id/tv_invite_more_bottom"
android:src="#drawable/ic_add" />
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageButton
android:maxHeight="20dp"
android:maxWidth="20dp"
android:layout_width="40dp"
android:background="#android:color/transparent"
android:layout_height="40dp"
android:src="#drawable/icon_bullet_list"
android:id="#+id/action_bulleted" />
<ImageButton
android:maxHeight="20dp"
android:maxWidth="20dp"
android:background="#android:color/transparent"
android:layout_width="40dp"
android:layout_height="40dp"
android:src="#drawable/icon_numbered_list"
android:id="#+id/action_unordered_numbered" />
</LinearLayout>
</RelativeLayout>
I would like my bottom layour above soft keyboard but it is having issue. Adjustpan doesn't work here.

Collapse Header View without Toolbar

I'm trying to collapse my header view in my fragment. I've tried using Collapsing Toolbar layout but it's not working. My toolbar is in my activity and my header and everything else is in a fragment. Any tips on how to achieve this? I'll post the codes of each page
fragment_post.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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:background="#color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.CollapsingToolbarLayout
android:layout_height="match_parent"
android:layout_width="match_parent"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:id="#+id/mainImageContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/purple"
android:minHeight="80dp"
android:orientation="horizontal"
android:weightSum="3"
app:layout_collapseMode="parallax">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="19dp"
android:layout_weight="0.5">
<TextView
android:id="#+id/numPosts"
android:layout_width="36dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginStart="15dp"
android:background="#drawable/ic_comments_bubble"
android:fontFamily="sans-serif-condensed"
android:gravity="center_horizontal"
android:paddingTop="5dp"
android:textColor="#color/purple"
android:textSize="14sp"
android:textStyle="bold" />
</RelativeLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_weight="2.4"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:id="#+id/threadTopic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:alpha="0.5"
android:fontFamily="sans-serif-condensed"
android:textColor="#android:color/white"
android:textSize="14sp" />
<TextView
android:id="#+id/threadText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="15dp"
android:layout_marginTop="13dp"
android:textColor="#android:color/white"
android:textSize="16sp" />
</LinearLayout>
<ImageButton
android:id="#+id/moreOptions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:alpha="0.5"
android:background="#drawable/ic_more_vert_white_24dp" />
</LinearLayout>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/postsRecyclerView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</LinearLayout>
<View
android:id="#+id/scrimColorView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/black_semi_transparent"
android:visibility="invisible"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/flipText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:visibility="invisible"
android:layout_marginEnd="10dp"
android:background="#color/white"
android:text="#string/flipText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/flipFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_flip"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
android:layout_marginStart="10dp"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/shareText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginEnd="20dp"
android:visibility="invisible"
android:background="#color/white"
android:text="#string/shareText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/shareFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:src="#drawable/ic_share_white"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/replyText"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:paddingTop="5dp"
android:paddingBottom="5dp"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:layout_marginEnd="19dp"
android:layout_marginTop="-46dp"
android:visibility="invisible"
android:background="#color/white"
android:text="#string/replyText"
android:textColor="#android:color/black"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/replyFab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="90dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="1dp"
android:src="#drawable/ic_reply"
android:visibility="invisible"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</LinearLayout>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
android:src="#drawable/ic_add"
app:backgroundTint="#color/mnBlue"
app:elevation="6dp"
app:pressedTranslationZ="12dp" />
</android.support.design.widget.CoordinatorLayout>
activity_post_pager.xml
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbarForPosts"
android:layout_width="match_parent"
android:background="#android:color/white"
android:minHeight="?android:attr/actionBarSize"
android:layout_height="wrap_content"
app:contentInsetStart="67dp">
<ImageButton
android:id="#+id/search_button"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end"
android:layout_marginEnd="20dp"
android:background="#drawable/ic_search"
android:src="#android:color/transparent"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/postPager"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</LinearLayout>
Thanks in advance

Categories

Resources