I would like to have my error tooltip displayed like in this image.
But mine is off like this
How can I fix this?
My layout code is 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"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".main.EditProfileActivity"
tools:showIn="#layout/activity_edit_profile">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dp"
android:orientation="vertical"
android:paddingBottom="56dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/label_margin_right"
android:src="#drawable/ic_account_grey600_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editTextNickname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:hint="#string/profile.nickname"
android:maxLength="16"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp" />
<Button
android:id="#+id/buttonNicknameClear"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|right"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:background="#drawable/ic_close_grey600_24dp"
android:onClick="onNicknameClearClicked"
android:padding="0dp"
android:visibility="invisible" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginEnd="#dimen/label_margin_right"
android:src="#drawable/ic_email_grey600_24dp" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<EditText
android:id="#+id/editTextEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="40dp"
android:hint="#string/profile.email"
android:inputType="textEmailAddress"
android:maxLength="30"
android:maxLines="1"
android:singleLine="true"
android:textSize="16sp" />
<Button
android:id="#+id/buttonEmailClear"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_vertical|right"
android:layout_marginStart="#dimen/activity_horizontal_margin"
android:background="#drawable/ic_close_grey600_24dp"
android:onClick="onEmailClearClicked"
android:padding="0dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
This happens to both first and second edit text.
What am I doing wrong?
EDIT:
I am adding extra code for more information.
This is the parent layout file.
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context=".main.EditProfileActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_edit_profile" />
</android.support.design.widget.CoordinatorLayout>
Try remove
android:paddingBottom="56dp"
Removing
app:layout_behavior="#string/appbar_scrolling_view_behavior" fixed the problem!
Thank you all!
Related
I have an AppBar and other things in my layout. When the user scrolls down, I want AppBar(actually, the Toolbar to hide. This is what I have tried, the app bar isn't hiding all small part it just stays there. Actually I think the problem is with my header of the screen it gets collapsed and adds a small space when I scroll.
As you can see in second image some part stays it doesn't hide. I need to hide that part while scrolling.
Please provide me solution what am I doing wrong?
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleTextAppearance="#style/TextAppearance.AppCompat.Title"
app:layout_scrollFlags="scroll|exitUntilCollapsed"
app:titleEnabled="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/slideIV"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_dish" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottomButtonRL"
android:layout_gravity="bottom"
android:background="#drawable/gradient_bg" />
<View style="#style/itemBottomViewLarge" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_margin="#dimen/_20"
android:gravity="center_vertical"
android:orientation="vertical">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#drawable/fake_chef_bg"
app:civ_border_color="#color/border_grey_color"
app:civ_border_width="#dimen/_2" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_5"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:text="#string/fatima_al_zahraa"
android:textColor="#color/white"
android:textSize="#dimen/large_text_size"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:text="#string/presenter_of_the_cuient"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<RelativeLayout
android:id="#+id/bottomButtonRL"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/slideIV"
android:layout_marginTop="-25dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1" />
<View
android:layout_width="match_parent"
android:layout_height="#dimen/_0"
android:layout_weight="1"
android:background="#color/defaultColor" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="#dimen/_20"
android:paddingLeft="#dimen/_20">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_share" />
<RelativeLayout
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/_10"
android:layout_marginLeft="#dimen/_10"
android:background="#drawable/ic_rec1">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fontFamily="#font/regular_font"
android:gravity="center"
android:layout_centerInParent="true"
android:text="#string/add_to_fav"
android:textColor="#color/white"
android:textSize="#dimen/medium_text_size" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/bottom_radius_view">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/regular_font"
android:padding="#dimen/_20"
android:text="#string/galetes_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates_fires_au_plates"
android:textColor="#color/white"
android:textSize="#dimen/app_text_size" />
</LinearLayout>
</LinearLayout>
<androidx.appcompat.widget.Toolbar
android:visibility="gone"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
/>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="#dimen/_20"
android:paddingTop="#dimen/_10"
android:paddingRight="#dimen/_20">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/bold_font"
android:padding="#dimen/_5"
android:text="#string/les_videos"
android:textColor="#color/medium_grey_text_color"
android:textSize="#dimen/large_text_size" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/itemFRV"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/_5" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</layout>
This is the header code:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="#dimen/header_height"
android:background="#color/white"
android:gravity="center"
android:orientation="horizontal"
android:paddingLeft="#dimen/_20"
android:paddingRight="#dimen/_20">
<LinearLayout
android:id="#+id/backLL"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="left"
android:gravity="center"
android:paddingRight="#dimen/_20"
android:layout_marginBottom="#dimen/_10"
android:visibility="gone">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:src="#drawable/ic_back" />
</LinearLayout>
<ImageView
android:id="#+id/logoIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:adjustViewBounds="true"
android:paddingStart="0dp"
android:paddingTop="#dimen/_15"
android:paddingEnd="#dimen/_10"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_header_logo" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<ImageView
android:id="#+id/profileIV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:adjustViewBounds="true"
android:paddingStart="#dimen/_10"
android:paddingTop="#dimen/_15"
android:paddingEnd="0dp"
android:layout_marginBottom="#dimen/_10"
android:src="#drawable/ic_default_user" />
</LinearLayout>
</layout>
Answer to the problem is just remove
android:fitsSystemWindows="true"
Change the layout_scrollFlags
app:layout_scrollFlags="scroll|exitUntilCollapsed"
replace above line with
app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed"
I implemented a floating action button in my layouts. The problem is when I have too much data in my layout, the button not stay in the same position, it scrolls to the bottom of the layout. I need the same like gmail inbox: a floating button that is always accesible no matter the data.
This is my code to show the button
<?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">
<include
android:id="#+id/frgOffline"
android:visibility="gone"
layout="#layout/frg_offline"/>
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" card_view:cardBackgroundColor="#android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="7dp"
android:layout_marginTop="7dp"
android:gravity="center_vertical|left">
<LinearLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="25dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="text"
android:layout_marginBottom="15dp"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<com.exampleapp.expandiblelist
android:id="#+id/expListaResultado"
android:groupIndicator="#null"
android:layout_height="fill_parent"
android:transcriptMode="disabled"
android:layout_width="match_parent"/>
</LinearLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnNueva"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="4dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="5dp"
android:src="#drawable/ic_nuevo"
android:layout_gravity="bottom|right"
app:backgroundTint="#color/blue"/>
</android.support.v7.widget.CardView>
</LinearLayout>
What's going on?
Thanks for helping!
You can see this code this will work fine with you
<?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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical">
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto" card_view:cardBackgroundColor="#android:color/white"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_marginBottom="7dp"
android:layout_marginTop="7dp"
android:gravity="center_vertical|left">
<LinearLayout
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="25dp"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="text"
android:layout_marginBottom="15dp"
android:textStyle="bold"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="15dp"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceSmall"/>
<com.exampleapp.expandiblelist
android:id="#+id/expListaResultado"
android:groupIndicator="#null"
android:layout_height="fill_parent"
android:transcriptMode="disabled"
android:layout_width="match_parent"/>
</LinearLayout>
</android.support.v7.widget.CardView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/btnNueva"
android:layout_width="48dp"
android:layout_height="48dp"
android:elevation="4dp"
android:layout_marginBottom="16dp"
android:layout_marginLeft="5dp"
android:src="#mipmap/ic_launcher"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp"
/>
</RelativeLayout>
you need coordinatorlayout for this
try this one, It might help
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="info.androidhive.fab.MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_main" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:src="#android:drawable/ic_dialog_email" />
</android.support.design.widget.CoordinatorLayout>
in content_main layout put all your necessary code..
My issue is the editText on the tabLayout is child fragment , when i input edittext the actionbar will up and disappear.
I try to add the android:windowSoftInputMode="adjustPan" or add ScrollView on the fragment xml, they are no working.
I can't find the same issue on internet.
Is anyone can teach me the solution,please.
Parent page:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#FFFFFF">
<!--my actionbar is overhere-->
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<!--Parent Fragment change from here-->
<FrameLayout
android:id="#+id/mainFrame"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"/>
</android.support.design.widget.CoordinatorLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="270dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#android:color/white"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu"
app:itemIconTint="#color/colorPrimary"/>
</android.support.v4.widget.DrawerLayout>
Child page:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/darker_gray"
android:orientation="vertical"
tools:context=".SubpagesLayout.Homepage">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#android:color/white"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light"
android:orientation="horizontal">
<ImageView
android:layout_width="80dp"
android:layout_height="80sp"
android:id="#+id/genderIcon"
android:layout_gravity="center"
android:layout_weight="1"
app:srcCompat="#drawable/photo_default_female" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/background_light">
<TextView
android:text="Name"
android:textColor="#android:color/black"
android:textSize="30dp"
android:textStyle="bold"
android:gravity="center"
android:layout_marginLeft="125dp"
android:id="#+id/textNameAges"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:text="543"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:background="#android:color/background_light"
android:layout_width="match_parent"
android:layout_height="10dp"></LinearLayout>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white">
<!--Child fragment change by the TabLayouts-->
<!--body_weight_fragment is one of the tabs-->
<android.support.design.widget.TabLayout
android:id="#+id/tabLayoutHomePage"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="1"
android:background="#color/colorPrimary"
app:tabTextColor="#android:color/white">
</android.support.design.widget.TabLayout>
<view
android:id="#+id/viewPager"
class="android.support.v4.view.ViewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" />
</android.support.design.widget.AppBarLayout>
</LinearLayout>
body_weight_fragment:
<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:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingTop="10dp">
<!--input editText will let actionbar disappear-->
<EditText
android:id="#+id/editHeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="cm"
android:inputType="number"
android:windowSoftInputMode="adjustPan" />
<Button
android:id="#+id/btnCaculate"
android:layout_width="2dp"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:background="#drawable/corner_pink"
android:text="caculate"
android:textColor="#android:color/white" />
<EditText
android:id="#+id/editWeight"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.3"
android:gravity="center"
android:hint="kg"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="show result"
android:paddingTop="8dp" />
</LinearLayout>
<com.github.mikephil.charting.charts.PieChart
android:id="#+id/chart"
android:layout_width="match_parent"
android:layout_height="match_parent"></com.github.mikephil.charting.charts.PieChart>
</LinearLayout>
try it in manifest: add (adjustResize + adjustPan) for parent activity
<activity
android:name="main"
android:windowSoftInputMode="adjustPan|adjustResize"/>
I found a solution by myself,i have to use scrollView include the toolaBar.Just like above
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v7.widget.Toolbar
android:id="#+id/id_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:theme="#style/ToolBarStyle"
app:layout_scrollFlags="scroll|enterAlways"
android:background="#FF6699">
<TextView
android:id="#+id/textTitle"
android:textSize="18dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#android:color/background_light" />
</android.support.v7.widget.Toolbar>
</ScrollView>
I just completed an app which is working as expected but when i run it on API 19 ---> API 16, i get a distorted UI where some of the views will overlap each other, the arrangement is disorganized and when you open another activity, the last activity UI is shown below the current activity. This error is weird to me because when i tested the app on API 22 + , it was working fine.
I tried to figure out the error but couldn't because i can't tell where the error is which left me in a confused state.
Below is the Screenshots of the aforementioned UI Behavior.
The UI XML Files
Cardview_row_article.xml
<?xml version="1.0" encoding="utf-8"?><!-- A CardView that contains a TextView -->
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cv"
android:layout_width="match_parent"
android:layout_height="110dp"
android:layout_marginTop="3dp"
card_view:cardCornerRadius="3dp"
card_view:cardPreventCornerOverlap="true"
android:foreground="?android:attr/selectableItemBackground"
card_view:cardUseCompatPadding="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/art_image"
android:layout_width="110dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:scaleType="fitXY"
android:src="#drawable/loading_item_img"
/>
<TextView
android:id="#+id/art_title"
android:layout_width="230dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textAlignment="center"
android:textSize="30dp"
android:layout_alignTop="#+id/art_image"
/>
<TextView
android:id="#+id/art_subTitle"
android:layout_width="220dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:textSize="15sp"
android:textStyle="italic"
android:textColor="#android:color/holo_red_dark"
android:textAlignment="center"/>
</RelativeLayout>
</android.support.v7.widget.CardView>
NewsDetail.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:id="#+id/coordinator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<!-- App Bar -->
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="#dimen/detail_backdrop_height"
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
android:fitsSystemWindows="true">
<!-- Collapser -->
<android.support.design.widget.CollapsingToolbarLayout
android:id="#+id/collapser"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleMarginEnd="64dp"
app:expandedTitleMarginStart="48dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<ImageView
android:id="#+id/image_paralax"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:scaleType="centerCrop"
app:layout_collapseMode="parallax"
android:src="#drawable/kenny"/>
<!-- Toolbar -->
<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="?attr/actionBarSize"
android:background="#android:color/transparent"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:theme="#style/CustomActionBar"
/>
</android.support.design.widget.CollapsingToolbarLayout>
<android.support.design.widget.FloatingActionButton
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="#id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:src="#drawable/ic_add"
android:layout_margin="#dimen/fab_margin"
android:clickable="true"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scroll"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/app_bar"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingTop="24dp">
<LinearLayout
style="#style/Widget.CardContent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/titleDetailTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:minLines="1"
android:text="Title"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/colorBlack"
android:textStyle="bold"
android:textSize="20dp"/>
<TextView
android:id="#+id/detailDetailTxt"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="DATE"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="#+id/timeDetailTxt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minLines="4"
android:padding="2dp"
android:text="details"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0f0f0f" />
</LinearLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fabsocial"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
app:layout_anchor="#id/appbar"
app:layout_anchorGravity="bottom|right|end"
android:src="#drawable/ic_share"
android:layout_margin="#dimen/fab_margin"
android:clickable="true"/>
</android.support.design.widget.CoordinatorLayout>
EmergencyActivity.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:support="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:orientation="vertical"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.domain.navdrawer.InerFragment"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="150dp"
android:orientation="vertical" >
<ImageView
android:id="#+id/emer_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/emergencyback"
android:layout_marginTop="6dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/emertop"
android:text="Emergency Report"
android:textSize="25sp"
android:textColor="#color/Color_Red"
android:gravity="center"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/input_layout_name"
>
<EditText
android:id="#+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/question_name_input_hint"
android:inputType="textAutoComplete" />
</android.support.design.widget.TextInputLayout>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RadioButton
android:id="#+id/emergency_type_fire"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/type_fire" />
<RadioButton
android:id="#+id/emergency_type_accident"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/type_accident" />
<RadioButton
android:id="#+id/emergency_type_robbery"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/type_robbery" />
<RadioButton
android:id="#+id/emergency_type_others"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/type_other" />
</RadioGroup>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_emergency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<EditText
android:id="#+id/input_emergency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:hint="#string/hint_emergency" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_email"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/input_email"
android:layout_width="match_parent"
android:inputType="textEmailAddress"
android:layout_height="wrap_content"
android:hint="#string/hint_mobile" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<Button
android:id="#+id/btn_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send"
android:layout_centerHorizontal="true"
android:textColor="#color/finestWhite"
android:background="#android:color/holo_red_dark"
android:layout_gravity="center"
android:layout_marginTop="15dp"
/>
</LinearLayout>
Well, i finally figured out the fix to the UI glitches.
All you have to do is Set the background of the root activity to 'White' in your activity xml files.
Thats just it!
This is my payout file.
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
It is displaying bottom card view items and toolbar. But not displaying recyclerView Items. items are available in recyclerView, But i am missing something in layout file (display part)
Can anyone help me what i am missing here?
You have not set layout_below property in cardview. That is why your recyclerview is overlapped by cardview
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:alignParentBottom="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
</RelativeLayout>
Try this..
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
android:layout_above="#+id/card_view"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:layout_alignParentBottom="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
try this i think it will solve your problem.....
<?xml version="1.0" encoding="utf-8"?>
<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"
xmlns:app="http://schemas.android.com/apk/res-auto"
tools:context="com.wokoshop.sony.activity.ActivityShoppingCart">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll|enterAlways"
android:layout_alignParentTop="true"/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:layout_below="#+id/toolbar"
/>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/card_view"
android:layout_below="#+id/recycler_view"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="8dp"
>
<CheckBox
android:id="#+id/applyWallet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Apply wallet"
android:checked="true"
android:layout_above="#+id/mainText"
/>
<TextView
android:id="#+id/mainText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="18sp"
android:textColor="#color/primary_dark"
android:layout_centerHorizontal="true"
android:layout_above="#+id/placeOrderButton"
/>
<Button
android:id="#+id/placeOrderButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="PLACE ORDER"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>