I have an app and I want to animate the keyboard something like this:
OR is the gif is not working, you can go to this url and get the gif.
Please ignore the first image. I am asking about the second one.
What do I need to do to achieve such an animation? This is my xml code:
<?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:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/fragmentContainer"
android:visibility="gone"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/appBarLayout"
app:layout_constraintTop_toTopOf="parent"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
app:navigationIcon="#drawable/left"
android:id="#+id/toolbar"
app:popupTheme="#style/Theme.MyApplication.PopupMenu">
<com.mikhaellopez.circularimageview.CircularImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher"
app:civ_border="false"
android:layout_margin="#dimen/_6sdp"/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingStart="#dimen/_10sdp"
android:gravity="center_vertical">
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Telegram"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="#dimen/_13sdp"/>
<View
android:layout_width="wrap_content"
android:layout_height="#dimen/_3sdp"/>
<TextView
android:id="#+id/lastSeenTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="last seen 1 minute ago"
android:textSize="#dimen/_9sdp"
android:textColor="#color/white"/>
</LinearLayout>
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/recyclerView"
app:layout_constraintTop_toBottomOf="#id/appBarLayout"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/bottomBar"
android:padding="#dimen/_5sdp"
android:background="#E4E4E4"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:reverseLayout="true"
/>
<LinearLayout
android:id="#+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="#dimen/_40sdp"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="#dimen/_40sdp"
android:orientation="horizontal"
android:background="#color/white">
<ImageView
android:id="#+id/emoji"
android:layout_width="#dimen/_23sdp"
android:layout_height="#dimen/_23sdp"
android:src="#drawable/emoji"
app:tint="#android:color/darker_gray"
android:layout_gravity="center_vertical"
android:layout_marginStart="#dimen/_7sdp"
android:background="?selectableItemBackgroundBorderless"/>
<com.vanniktech.emoji.EmojiEditText
android:id="#+id/message"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Message"
android:maxHeight="#dimen/_100sdp"
android:textColorHint="#android:color/darker_gray"
android:paddingVertical="#dimen/_7sdp"
android:paddingHorizontal="#dimen/_7sdp"
android:textColor="#android:color/darker_gray"
tools:text="#string/sample_long_text"
android:backgroundTint="#android:color/transparent"
tools:ignore="HardcodedText" />
<ImageView
android:id="#+id/send"
android:layout_width="#dimen/_23sdp"
android:layout_height="#dimen/_23sdp"
android:src="#drawable/send"
app:tint="#android:color/darker_gray"
android:layout_gravity="center_vertical"
android:layout_marginHorizontal="#dimen/_7sdp"
android:background="?selectableItemBackgroundBorderless"/>
</LinearLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Related
:)
I want to change my constraintlayout to a LinearLayout. I tried it with the green (second area) and it worked perfectly. Unfortunately, the top part doesn't work as well as the bottom part. The problem is that the red area always occupies the entire area and does not go to the toolbar.
How can I make the height of the red area only up to the toolbar + distance?
I don't want to change something "more" in my Toolbar XML, otherwise the layout on all other pages is wrong.
Is there an option that allows android: layout_height = "match_parent- toolbar"?
I would like it to end up looking like the second picture. The red area should be at a distance from the toolbar and be at a maximum. So no matter how much content is in the red area, it should always be as large as possible by far. How can I do that? I'm really looking forward to helpful answers! Thanks in advance.
My current status:
What I want to achieve:
My try
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ececec"
android:orientation="horizontal">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:gravity="center"
app:cardBackgroundColor="#color/Red"
app:cardCornerRadius="15dp">
</androidx.cardview.widget.CardView>
</LinearLayout>
XML
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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="#ececec">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:gravity="center"
app:cardBackgroundColor="#color/Red"
app:cardCornerRadius="15dp"
app:layout_constraintBottom_toTopOf="#+id/cardViewCheckout"
app:layout_constraintTop_toTopOf="parent">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardViewCheckout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="10dp"
android:elevation="8dp"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_gravity="center">
<TextView
android:id="#+id/textViewSumme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Summe "
android:layout_gravity="center"/>
<TextView
android:id="#+id/textViewSumme2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0,00"
android:layout_gravity="center"/>
</LinearLayout>
<Button
android:id="#+id/btn_user_geldaufladen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/button_order_checkout"
android:backgroundTint="#04C3B1"
android:elevation="16dp"
android:text="AUFLADEN"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_marginBottom="10sp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>
Toolbar
<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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".UserHomeActivity">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</com.google.android.material.appbar.AppBarLayout>
<include layout="#layout/user_content_main"
/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
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"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ececec"
android:padding="16dp"
android:orientation="vertical"
android:layout_below="#+id/appBar"
android:weightSum="10">
<androidx.cardview.widget.CardView
android:id="#+id/cardViewMiddle"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="7"
android:layout_gravity="center"
android:layout_marginBottom="8dp"
android:elevation="8dp"
android:layout_marginEnd="24dp"
android:layout_marginStart="24dp"
android:gravity="center"
app:cardBackgroundColor="#f00"
app:cardCornerRadius="15dp"
app:layout_constraintBottom_toTopOf="#+id/cardViewCheckout"
app:layout_constraintTop_toTopOf="parent">
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cardViewCheckout"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="3"
android:layout_marginStart="24dp"
android:layout_marginEnd="24dp"
android:layout_marginBottom="10dp"
android:elevation="8dp"
app:cardBackgroundColor="#fff"
app:cardCornerRadius="15dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginTop="5sp"
android:layout_marginBottom="5sp"
android:layout_gravity="center">
<TextView
android:id="#+id/textViewSumme"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Summe "
android:layout_gravity="center"/>
<TextView
android:id="#+id/textViewSumme2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="0,00"
android:layout_gravity="center"/>
</LinearLayout>
<Button
android:id="#+id/btn_user_geldaufladen"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#color/colorPrimaryDark"
android:backgroundTint="#04C3B1"
android:elevation="16dp"
android:text="AUFLADEN"
android:textColor="#FFFFFF"
android:textStyle="bold"
android:layout_marginBottom="10sp"/>
</LinearLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/appBar"
>
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="?attr/colorPrimary"
/>
</com.google.android.material.appbar.AppBarLayout>
</RelativeLayout>
Could you try to replace your (include) tag with this:
<include layout="#layout/user_content_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior"
/>
I need windowSoftInputMode= adjustRezise for my layout so that my buttons go up with the keyboard. BUT I don't want my BottomNagivationView to be affected by this.
How can I solve such?
My BottomNavigationView comes from MainActivity.xml which is:
<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=".MainActivity">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_navigation"></FrameLayout>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
app:menu="#menu/bottom_menu"/>
</RelativeLayout>
My manifest has android:windowSoftInputMode="adjustPan" but I adjust it by code when I open the fragment with:
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Here are some pictures so you could understand what I mean: https://imgur.com/a/vjePxI6
So what I would like to know is how I could set the BottomNavigationView to do nothing on keyboard opening while I'd like my buttons to be affected by :
getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
In my case problem solved by just adding following line in manifest file.
android:windowSoftInputMode="adjustResize|adjustPan"
add android:windowSoftInputMode="adjustPan" inside your activity tag into your manifest file.
then go to your activity and change the parent layout to RelativeLayout, then create your FrameLayout which holds your fragments inside your relative layout which is your parent layout. Then add your second layout which is LinearLayout that holds the bottomNavigationView and make its Height and width match_parent but below the FrameLayout.
Below is the example of the main 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"
android:orientation="vertical"
tools:context=".MainActivity">
//FrameLayout which holds all your fragments
<FrameLayout
android:id="#+id/fragments_container"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</FrameLayout>
//BottomNavigationView Container
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:layout_below="#id/fragments_container">
//BottomMenus
<com.google.android.material.bottomnavigation.BottomNavigationView
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:id="#+id/bottom_navigation"
android:background="#drawable/rectangle_4_dash"
android:layout_alignParentBottom="true">
//Container of Menus
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:weightSum="5">
//BottomMenu One
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/home_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Home" />
</LinearLayout>
//BottomMenu Two
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/contact_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="Contact" />
</LinearLayout>
//BottomMenu Three
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center"
android:src="#drawable/about_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="About"
android:layout_gravity="center"/>
</LinearLayout>
//BottomMenu Four
<LinearLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical">
<ImageView
android:layout_width="20dp"
android:layout_height="17dp"
android:layout_gravity="center"
android:src="#drawable/services_icon" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Services"
android:layout_gravity="center"/>
</LinearLayout>
</LinearLayout>
</com.google.android.material.bottomnavigation.BottomNavigationView>
</LinearLayout>
Then go to your fragment which you want to scroll and design it like below one.
<?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">
<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">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Title Of Your Form"
android:textAlignment="center"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="20dp">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/f_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/m_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="#string/l_name"
android:inputType="textPersonName"
android:padding="10dp"
android:textSize="14sp" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Message"
android:inputType="text"
android:padding="10dp"
android:textSize="14sp" />
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:text="Send Messagge"
android:textAllCaps="false"
android:textColor="#color/white"
android:layout_marginBottom="40dp"/>
</LinearLayout>
</ScrollView>
That is how i solved it,
if you have any doubt please let me know but if its helps or looks like a correct answer please mark it as a correct answer thanks.
I have made a RecyclerView Adapter inflated in a CardView as shown in the images below. The cards have hidden layouts which become visible after being clicked on.
I am having a problem that when I have many sets of data as cards, and expand one or more cards, some of the cards become abnormal and invisible indefinitely. The cards not in current screen appear to face this problem.
\
When I scroll through the cards the view becomes more complicated and some cards become smaller and leave white spaces between them while content being of same size.
Please anyone help me solve the problem..
EDIT: This is my layout file:
open_up_list_view.xml
<?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"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/openUpCardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/nav_header_vertical_spacing"
android:layout_marginEnd="#dimen/dimen_16x"
android:layout_marginLeft="#dimen/activity_vertical_margin"
android:layout_marginRight="#dimen/dimen_16x"
android:layout_marginStart="#dimen/activity_vertical_margin"
android:layout_marginTop="#dimen/dimen_4x"
android:clickable="true"
android:focusable="true"
app:cardCornerRadius="#dimen/dimen_8x">
<RelativeLayout
android:id="#+id/openUpRelativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/dimen_8x"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ProgressBar
android:id="#+id/openUpAuthorImageProgress"
android:layout_width="wrap_content"
android:layout_height="match_parent" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/openUpAuthorImage"
android:layout_width="#dimen/dimen_48x"
android:layout_height="#dimen/dimen_48x"
android:layout_marginBottom="#dimen/dimen_4x"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginRight="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_4x"
app:civ_border_color="#FF000000"
app:civ_border_width="2dp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/openUpAuthorName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/cardview_default_radius"
android:layout_marginLeft="#dimen/dimen_8x"
android:layout_marginRight="#dimen/dimen_8x"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textColor="#color/colorPrimaryDark"
android:textSize="#dimen/dimen_16x"
android:textStyle="bold" />
<TextView
android:id="#+id/openUpDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/openUpAuthorName"
android:layout_marginLeft="#dimen/dimen_8x"
android:textSize="#dimen/dimen_12x" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="#+id/openUpTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_gravity="left"
android:autoLink="web"
android:padding="#dimen/dimen_4x"
android:textAlignment="textStart"
android:textColor="#color/cardview_dark_background"
android:textSize="#dimen/dimen_16x" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:id="#+id/openUpImageProgress"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.github.chrisbanes.photoview.PhotoView
android:id="#+id/openUpImageView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/dimen_8x"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginRight="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_8x"
android:layout_weight="1"
app:srcCompat="#drawable/common_google_signin_btn_icon_dark" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:background="#android:color/darker_gray"
android:hapticFeedbackEnabled="false"></View>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<CheckBox
android:id="#+id/openUpLikeIcon"
android:layout_width="#dimen/dimen_32x"
android:layout_height="#dimen/dimen_24x"
android:layout_marginBottom="#dimen/dimen_4x"
android:layout_marginLeft="16dp"
android:layout_marginStart="16dp"
android:layout_marginTop="8dp"
android:background="#drawable/thumb_off"
android:button="#null"
android:checked="false"
android:clickable="true"
android:focusable="true"
android:stateListAnimator="#animator/scale"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toBottomOf="#+id/image" />
<TextView
android:id="#+id/openUpLikeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/nav_header_vertical_spacing"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textSize="#dimen/dimen_16x" />
<ImageView
android:id="#+id/openUpCommentIcon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="#dimen/fab_margin"
android:layout_marginTop="#dimen/dimen_8x"
app:srcCompat="#drawable/comment_icon" />
<TextView
android:id="#+id/openUpCommentTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dimen_8x"
android:text="loading.."
android:textSize="#dimen/dimen_16x" />
<TextView
android:id="#+id/openUpDeleteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/dimen_4x"
android:layout_marginTop="#dimen/dimen_8x"
android:layout_weight="1"
android:gravity="center_horizontal"
android:text="Delete"
android:textSize="#dimen/dimen_16x" />
</LinearLayout>
<View
android:id="#+id/commentSeparatorView"
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:layout_marginTop="#dimen/nav_header_vertical_spacing"
android:background="#color/colorPrimaryDark"
android:hapticFeedbackEnabled="false"></View>
<TextView
android:id="#+id/commentSeparatorText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="#dimen/dimen_8x"
android:gravity="center"
android:text="Comments"
android:textColor="#color/common_google_signin_btn_text_dark_focused" />
<LinearLayout
android:id="#+id/commentsLL"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="#dimen/dimen_4x"
android:background="#null"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/commentsRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Add a comment..">
<android.support.design.widget.TextInputEditText
android:id="#+id/commentEditText"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<android.support.v7.widget.AppCompatButton
android:id="#+id/commentPostButton"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:backgroundTint="#color/colorPrimaryDark"
android:text="POST"
android:textColor="#color/cardview_light_background" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
how can I overlap images half on one another from layout XML file like this image.
Simply you can use RealtiveLayout and negative margins
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_landing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/screen_background">
<ImageView
android:background="#color/black"
android:id="#+id/img_background"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#mipmap/ic_launcher" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_below="#+id/img_background"
android:layout_centerHorizontal="true"
android:layout_marginTop="-40dp"<!-- negative margin to half of height -->
android:src="#mipmap/ic_launcher" />
</RelativeLayout>
The FrameLayout is more optimised to perform this function. I carries less overhead.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/activity_landing"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="#+id/img_background"
android:layout_width="match_parent"
android:layout_height="500dp"
android:src="#mipmap/ic_launcher"
android:background="#color/colorPrimary"/>
<ImageView
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_below="#+id/img_background"
android:layout_gravity="bottom|center_horizontal"
android:src="#mipmap/ic_launcher"
android:background="#color/cardview_dark_background"/>
</FrameLayout>
This can be achieve easily by RelativeLayout but you need to look about CoordinatorLayout and its features.
<RelativeLayout
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_90sdp">
<ImageView
android:id="#+id/bg"
android:layout_width="match_parent"
android:layout_height="#dimen/_90sdp"
android:background="#color/profile_bg"
android:scaleType="fitXY" />
<ImageView
android:id="#+id/img_user"
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_below="#+id/bg"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/_minus50sdp"
android:src="#drawable/place_holder_profile"/>
</RelativeLayout>
Use this dependencies compile 'com.intuit.sdp:sdp-android:1.0.2'
https://github.com/intuit/sdp
You have to set the margin Top with minus(-) values.It will overlap your image view with other
try this, it look like this
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/cc"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.4"
android:src="#drawable/a123123t"/>
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<!--blank space-->
</FrameLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal">
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image1"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image2"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/profile_image3"
android:layout_width="96dp"
android:layout_height="96dp"
android:src="#drawable/cc"
android:padding="8dp"
android:layout_gravity="center"
app:civ_border_width="2dp"
app:civ_border_color="#FF000000"
android:layout_centerInParent="true"
/>
</FrameLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical">
<android.support.v4.widget.Space
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Edit Profile"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
for dependencies :
compile 'de.hdodenhof:circleimageview:2.1.0'
try this on
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/layout_background">
<ImageView
android:id="#+id/img_background"
android:layout_width="match_parent"
android:layout_height="108dp"
android:background="#color/up"
android:src="#mipmap/ic_launcher" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/nav_header_view_profilePic"
android:layout_width="108dp"
android:layout_height="108dp"
android:layout_below="#+id/img_background"
android:src="#drawable/profile"
android:layout_marginTop="-54dp"
android:layout_centerHorizontal="true"
/>
</RelativeLayout>
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ll_mainProfile"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/gradientLeft"
android:orientation="vertical"
tools:context=".Activity.ProfileActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/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_profileActivity"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#drawable/side_nav_bar"
app:popupTheme="#style/AppTheme.PopupOverlay"
app:titleTextColor="#color/white" />
</android.support.design.widget.AppBarLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/header_cover_image"
android:layout_width="match_parent"
android:layout_height="250dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="centerCrop"
android:src="#drawable/background" />
<ImageView
android:id="#+id/img_profile"
android:layout_width="200dp"
android:layout_height="200dp"
android:layout_below="#+id/header_cover_image"
android:layout_centerHorizontal="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="-130dp"
android:elevation="5dp"
android:scaleType="centerCrop"
android:src="#drawable/ic_profile" />
<RelativeLayout
android:id="#+id/profile_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header_cover_image"
android:elevation="4dp"
android:paddingBottom="24dp">
<ImageView
android:id="#+id/img_editProfile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginStart="16dp"
android:layout_marginTop="20dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="30dp"
android:clickable="true"
android:src="#android:drawable/ic_menu_edit"
android:visibility="gone" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/img_editProfile"
android:gravity="center_horizontal"
android:orientation="vertical"
android:layout_marginTop="80dp"
android:paddingStart="20dp"
android:paddingEnd="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<EditText
android:id="#+id/et_fnameProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#color/black_overlay"
android:editable="true"
android:hint="#string/hint_first_name"
android:inputType="textPersonName"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_lnameProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#color/black_overlay"
android:editable="true"
android:hint="#string/hint_last_name"
android:inputType="textPersonName"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginBottom="10dp">
<EditText
android:id="#+id/et_countryCodeProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#color/black_overlay"
android:editable="true"
android:hint="#string/hint_country_code"
android:inputType="number"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="18sp" />
<EditText
android:id="#+id/et_mobileNoProfile"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:backgroundTint="#color/black_overlay"
android:editable="true"
android:hint="#string/hint_mobile_no"
android:inputType="number"
android:paddingStart="10dp"
android:paddingEnd="10dp"
android:textColor="#color/white"
android:textColorHint="#color/white"
android:textSize="18sp" />
</LinearLayout>
</LinearLayout>
<ProgressBar
android:id="#+id/progress_profile"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
</LinearLayout>
In Image view use this line
android:elevation="#dimen/dp5"
My layout is squeezing a little when keyboard pops up.
Here is my xml file
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
android:focusable="true"
android:focusableInTouchMode="true">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:background="#android:color/white">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:weightSum=".9"
android:layout_weight="2"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="1dp"
android:layout_weight=".01" />
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_weight=".3"
android:paddingLeft="12dp"
android:id="#+id/username"
android:hint="#string/username"
android:textColorHint="#color/edittextcolor"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginLeft="10dp"
android:hint="#string/password"
android:layout_weight=".3"
android:paddingLeft="12dp"
android:textColorHint="#color/edittextcolor"
android:layout_marginRight="10dp"
android:id="#+id/password" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight=".7"
android:weightSum="2"
android:layout_marginTop="30dp">
<Button
android:id="#+id/signup"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/Sign"
android:textColor="#android:color/white"
android:layout_marginLeft="20dp" />
<Button
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:text="#string/login"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="4" >
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="3"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
The layout is looking good when the keyboard is not appearing.I have added
android:windowSoftInputMode="adjustResize" in the mainifest file.But still it isn't working.
Any help will be much appreciated.Thanks in advance..
Change
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="10"
android:background="#android:color/white">
to
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
Hope your problem will be solved.