Original problem of menu item's not opening activity was solved by removing all the XML code incide ConstraintLayout. I added NavigationDrawer after creating all the stuff inside ConstraintLayout. How can i make both NavigationDrawer and my own stuff work together?
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_screen_image"
android:fitsSystemWindows="true"
tools:context=".HomeScreen"
tools:openDrawer="start">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/purple_200"
android:elevation="4dp"
android:theme="#style/ThemeOverlay.AppCompat.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light" />
<!--Dark text
android:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"-->
<!-- Container for fragments-->
<!--<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent" />-->
</LinearLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
app:headerLayout="#layout/nav_header"
app:menu="#menu/drawer_menu" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp">
<ImageView
android:id="#+id/homeScreenLogo"
android:layout_width="160dp"
android:layout_height="160dp"
android:layout_gravity="center"
android:src="#drawable/kaznau_logo"
app:layout_constraintBottom_toTopOf="#+id/guideline6"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="#+id/linearLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.4"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline6">
<com.google.android.material.button.MaterialButton
android:id="#+id/btnAboutUniversity"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_university"
android:text="#string/s_about_kaznau"
app:cornerRadius="5dp" />
<View
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btnFaculties"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_faculty"
android:text="#string/s_faculty"
app:cornerRadius="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout">
<com.google.android.material.button.MaterialButton
android:id="#+id/btnNews"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_baseline_article_24"
android:text="#string/s_news"
app:cornerRadius="5dp" />
<View
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btnEvents"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_baseline_event_24"
android:text="#string/events_name"
app:cornerRadius="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout2">
<com.google.android.material.button.MaterialButton
android:id="#+id/btnLocations"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_location"
android:text="#string/s_locations"
app:cornerRadius="5dp" />
<View
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btnCampus"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_campus"
android:text="#string/s_campus"
app:cornerRadius="5dp" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout3">
<com.google.android.material.button.MaterialButton
android:id="#+id/btnLinks"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_links"
android:text="#string/s_links"
app:cornerRadius="5dp" />
<View
android:layout_width="0dp"
android:layout_height="20dp"
android:layout_weight="1" />
<com.google.android.material.button.MaterialButton
android:id="#+id/btnContacts"
android:layout_width="160dp"
android:layout_height="50dp"
android:drawableLeft="#drawable/ic_contacts"
android:text="#string/s_contacs"
app:cornerRadius="5dp" />
</LinearLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/btnAgrodamu"
android:layout_width="wrap_content"
android:layout_height="50dp"
android:layout_gravity="center"
android:text="#string/s_agrodamu"
app:cornerRadius="5dp"
app:layout_constraintBottom_toTopOf="#+id/guideline7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.555"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/linearLayout4"
app:layout_constraintVertical_bias="0.164" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="20dp"
app:layout_constraintGuide_percent="0.4" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="20dp"
app:layout_constraintGuide_percent="0.9" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.drawerlayout.widget.DrawerLayout>
I would be appreciated if you can also tell me how to make my XML code more clean, without losing the functionality and look of it. Thanks
Okay, I figured it out. You have to put the NavigationView at the bottom before closing the DrawerLayout tag
Related
I have a carousel and I want to make the current card fullscreen on click. When the current card is fullscreen some additional data should be visible.
I am new to Android and I have the feeling that I am doing something wrong. I have already tried to implement it via different onClickListeners and Animations (because i also need a smooth transition), but nothing worked.
Does anyone has a suggestion on how to achieve this? (please see my carousel layout implementation below)
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/motion_layout_carousel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="invisible"
app:layout_constraintTop_toBottomOf="#+id/player_image_with_elements"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
app:layoutDescription="#xml/demo_020_carousel_scene">
<LinearLayout
android:id="#+id/imageView0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:orientation="vertical"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/imageView1"
app:layout_constraintTop_toTopOf="parent">
<include
layout="#layout/match_statistic"
android:background="#drawable/layout_rounded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="5dp"
android:orientation="vertical"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/imageView2"
app:layout_constraintTop_toTopOf="parent">
<include
layout="#layout/match_statistic"
android:background="#drawable/layout_rounded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<include
layout="#layout/match_statistic"
android:background="#drawable/layout_rounded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView2"
app:layout_constraintTop_toTopOf="parent">
<include
layout="#layout/match_statistic"
android:background="#drawable/layout_rounded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/imageView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5dp"
android:orientation="vertical"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="#+id/imageView3"
app:layout_constraintTop_toTopOf="parent">
<include
layout="#layout/match_statistic"
android:background="#drawable/layout_rounded"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_begin="50dp" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_end="50dp" />
<androidx.constraintlayout.helper.widget.Carousel
android:id="#+id/carousel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:carousel_backwardTransition="#+id/backward"
app:carousel_firstView="#+id/imageView2"
app:carousel_forwardTransition="#+id/forward"
app:carousel_nextState="#+id/next"
app:carousel_previousState="#+id/previous"
app:carousel_touchUpMode="carryVelocity"
app:carousel_touchUp_dampeningFactor="0.8"
app:constraint_referenced_ids="imageView0,imageView1,imageView2,imageView3,imageView4" />
</androidx.constraintlayout.motion.widget.MotionLayout>
<?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"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="app.redtaxi.client.views.chat.ChatViewModel" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/lesser_white"
android:gravity="bottom"
android:paddingTop="25dp"
tools:context=".views.chat.ChatActivity">
<RelativeLayout
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp"
android:background="#drawable/round_shape"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:onClick="#{() -> viewModel.onBackBtnClicked()}">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:padding="10dp"
android:src="#drawable/ic_back_arrow" />
</RelativeLayout>
<ImageView
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="16dp"
android:background="#drawable/round_shape"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:onClick="#{() -> viewModel.onCallBtnClicked()}"
android:src="#drawable/ic_call_black" />
<TextView
android:id="#+id/chat_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Mr. Samer Saadeh"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/chat_car_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/chat_title_tv"
android:layout_centerHorizontal="true"
android:text="17 - White Hyundai"
android:textColor="#color/text_gray"
android:textSize="14sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/chat_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/chat_layout"
android:layout_below="#id/chat_car_tv"
android:layout_marginTop="5dp"
tools:itemCount="15"
tools:listitem="#layout/item_chat" />
<LinearLayout
android:id="#+id/chat_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="45dp"
android:orientation="horizontal"
android:paddingStart="15dp"
android:paddingEnd="15dp">
<com.google.android.material.card.MaterialCardView
android:id="#+id/chat_cv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.9"
android:elevation="5dp"
android:theme="#style/Theme.MaterialComponents.Light"
app:cardCornerRadius="30dp"
app:strokeColor="#color/gray_light"
app:strokeWidth="0.5dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:padding="10dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/chat_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:ems="11"
android:hint="#string/type_a_message"
android:singleLine="true"
android:textColor="#color/text_black"
android:textColorHint="#color/hint_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.7" />
<ImageView
android:id="#+id/chat_attach_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="10dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_attach"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/chat_camera_iv"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/chat_camera_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="15dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_camera"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="#+id/chat_record_iv"
android:layout_width="50dp"
android:layout_height="50dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_mic_btn" />
</LinearLayout>
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout>
this is the XML file for the activity i have windowFullscreen set to false in my theme and i have tried adjustResize and adjustPan in the manifest and i tried setting it by code i also tried with and without the out RelativeLayout the Keyboard always covers the recyclerView and the editText feel free to ask me for other prats of the code
Image showing the UI
Can you try this? Remove the Linear Layout containing the TextInputEditText out of the NestedScrollView and set windowSoftInputMode to adjustResize like this:
In the manifest file:
android:windowSoftInputMode="adjustResize"
and the layout file like this:
<?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"
xmlns:tools="http://schemas.android.com/tools">
<data>
<variable
name="viewModel"
type="app.redtaxi.client.views.chat.ChatViewModel" />
</data>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:isScrollContainer="true"
android:scrollbars="none">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/lesser_white"
android:gravity="bottom"
android:paddingTop="25dp"
tools:context=".views.chat.ChatActivity">
<RelativeLayout
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="16dp"
android:background="#drawable/round_shape"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:onClick="#{() -> viewModel.onBackBtnClicked()}">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:padding="10dp"
android:src="#drawable/ic_back_arrow" />
</RelativeLayout>
<ImageView
android:layout_width="42dp"
android:layout_height="42dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="16dp"
android:background="#drawable/round_shape"
android:clickable="true"
android:elevation="4dp"
android:focusable="true"
android:onClick="#{() -> viewModel.onCallBtnClicked()}"
android:src="#drawable/ic_call_black" />
<TextView
android:id="#+id/chat_title_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:text="Mr. Samer Saadeh"
android:textColor="#color/black"
android:textSize="18sp"
android:textStyle="bold" />
<TextView
android:id="#+id/chat_car_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/chat_title_tv"
android:layout_centerHorizontal="true"
android:text="17 - White Hyundai"
android:textColor="#color/text_gray"
android:textSize="14sp"
android:textStyle="bold" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/chat_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/chat_layout"
android:layout_below="#id/chat_car_tv"
android:layout_marginTop="5dp"
tools:itemCount="15"
tools:listitem="#layout/item_chat" />
</RelativeLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:id="#+id/chat_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="5dp"
android:layout_marginBottom="45dp"
android:orientation="horizontal"
android:paddingStart="15dp"
android:paddingEnd="15dp">
<com.google.android.material.card.MaterialCardView
android:id="#+id/chat_cv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="0.9"
android:elevation="5dp"
android:theme="#style/Theme.MaterialComponents.Light"
app:cardCornerRadius="30dp"
app:strokeColor="#color/gray_light"
app:strokeWidth="0.5dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:padding="10dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/chat_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#null"
android:ems="11"
android:hint="#string/type_a_message"
android:singleLine="true"
android:textColor="#color/text_black"
android:textColorHint="#color/hint_gray"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.7" />
<ImageView
android:id="#+id/chat_attach_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="10dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_attach"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#id/chat_camera_iv"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="#+id/chat_camera_iv"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_marginEnd="15dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_camera"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
<ImageView
android:id="#+id/chat_record_iv"
android:layout_width="50dp"
android:layout_height="50dp"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_mic_btn" />
</LinearLayout>
</RelativeLayout>
I'm trying to add a horizantal recyclerview at the bottom in linearlayout but it always starts from top of linearlayout , here is my code
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
<androidx.fragment.app.FragmentContainerView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_container_view"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<androidx.cardview.widget.CardView
android:id="#+id/cardView"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="16dp"
android:layout_marginRight="16dp"
android:background="#color/white"
android:divider="#android:color/transparent"
android:elevation="100dp"
android:foreground="?android:attr/selectableItemBackground"
android:orientation="vertical"
app:cardBackgroundColor="#android:color/white"
app:cardCornerRadius="6dp"
app:cardElevation="66dp"
app:cardPreventCornerOverlap="false"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.076"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_image_view"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_marginStart="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/menu_icon" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:layoutDirection="ltr"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="#+id/frameLayout2"
app:layout_constraintStart_toEndOf="#+id/menu_image_view"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:id="#+id/medfast_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layoutDirection="ltr"
android:orientation="horizontal"
android:visibility="visible">
<com.plus.medfast.customViews.views.CustomRegularTextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/be_healthy" />
</LinearLayout>
<LinearLayout
android:id="#+id/zinc_linear_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:gravity="center"
android:layoutDirection="ltr"
android:orientation="horizontal"
android:visibility="gone">
<ImageView
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_weight="1.3"
android:src="#drawable/medfast_word_only" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="3dp"
android:layout_marginRight="-2dp"
android:layout_weight="1.7"
android:gravity="center">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/ic_deal" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:src="#drawable/zinc" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.9">
<FrameLayout
android:id="#+id/frameLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1.1"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/medfast_ads_image_view"
android:layout_width="40dp"
android:layout_height="50dp"
android:layout_gravity="left"
android:src="#drawable/ic_logo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/medfast_ads_text_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:layout_marginTop="24dp"
android:background="#drawable/circle_view_white_solid"
android:gravity="center"
android:text="10"
android:textColor="#color/white"
android:textSize="10dp"
app:layout_constraintBottom_toTopOf="#+id/medfast_ads_image_view"
app:layout_constraintEnd_toEndOf="#+id/medfast_ads_image_view"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
<FrameLayout
android:id="#+id/frameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="8dp"
android:layout_weight="1.3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/normal_ads_image_view"
android:layout_width="30dp"
android:layout_height="40dp"
android:layout_gravity="left"
android:src="#drawable/ic_notification"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="#+id/normal_ads_text_view"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_gravity="top|end"
android:layout_marginTop="16dp"
android:background="#drawable/circle_view_white_solid"
android:gravity="center"
android:text="10"
android:textColor="#color/white"
android:textSize="10dp"
app:layout_constraintBottom_toTopOf="#+id/normal_ads_image_view"
app:layout_constraintEnd_toEndOf="#+id/normal_ads_image_view"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>
</LinearLayout>
</LinearLayout>
</androidx.cardview.widget.CardView>
<ProgressBar
android:id="#+id/progressBar"
style="?android:attr/progressBarStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:layout_width="match_parent"
android:gravity="bottom"
android:layout_height="wrap_content"
app:layout_constraintBottom_toTopOf="#+id/focused_service_name_text_view"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/services_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false" />
</LinearLayout>
<com.plus.medfast.customViews.views.CustomBoldTextView
android:id="#+id/focused_service_name_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:gravity="center"
android:textColor="#color/colorPrimary"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<com.google.android.material.navigation.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/nav_header_maps_navigation_drawer"
app:menu="#menu/core_activity_navigation_drawer" />
</androidx.drawerlayout.widget.DrawerLayout>
but the result as shown bellow, i need the recyclerview be in bottom because i wan't to translate Y axis of the view to up
Everything in my xml is well written.
after adding marginTop=20 to the recycler view item it works well
<?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:id="#+id/root_view"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="80dp"
android:layout_height="80dp"
android:background="#drawable/circle_view_red"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:id="#+id/service_image_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:padding="5dp" />
<com.plus.medfast.customViews.views.CustomBoldTextView
android:id="#+id/service_name_text_view"
android:layout_width="60dp"
android:layout_height="match_parent"
android:layout_marginTop="-5dp"
android:gravity="center"
android:text="Test"
android:textColor="#color/white"
android:textSize="10dp"
android:visibility="visible" />
</LinearLayout>
</LinearLayout>
I want to remove white space that I show in picture
Picure
I draw red circle around white space on picture
and I want remove it
I search in stackoverflow but in that case i can not find any anwswer.
My main layout is -->
toolbar_normal.xml:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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"
tools:context=".MainActivity">
<include layout="#layout/city_detail_act"
android:id="#+id/content"/>
<android.support.v7.widget.Toolbar
android:id="#+id/tolbar_storyButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#66cc66"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
>
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal"
tools:layout_editor_absoluteX="16dp">
<ImageView
android:id="#+id/imgSetting"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/setting" />
<ImageView
android:id="#+id/imgChoiceCity"
android:layout_width="80dp"
android:layout_height="50dp"
android:layout_marginStart="181dp"
android:layout_marginLeft="181dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="180dp"
android:layout_marginRight="180dp"
android:layout_marginBottom="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/choicecity" />
<ImageView
android:id="#+id/imageViewButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="false"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/home" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
</android.support.constraint.ConstraintLayout>
My second layout is -->
city_detail_act.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="top"
android:paddingBottom="65dp"
>
<android.support.v7.widget.Toolbar
android:id="#+id/tolbar_story"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#66cc66"
android:minHeight="?attr/actionBarSize"
android:theme="?attr/actionBarTheme"
app:contentInsetLeft="0dp"
app:contentInsetStart="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:gravity="center"
android:orientation="horizontal"
tools:layout_editor_absoluteX="16dp">
<ImageView
android:id="#+id/imgTooTitlelbarMainActf"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_marginStart="16dp"
android:layout_marginLeft="16dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/adamak" />
<ImageView
android:id="#+id/imgTooTitlelbarMainAct"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginStart="180dp"
android:layout_marginLeft="180dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="181dp"
android:layout_marginRight="181dp"
android:layout_marginBottom="3dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/title" />
<ImageView
android:id="#+id/imgNavigationView"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginBottom="8dp"
android:adjustViewBounds="false"
android:scaleType="centerInside"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="#drawable/dot" />
</android.support.constraint.ConstraintLayout>
</android.support.v7.widget.Toolbar>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/tx_state6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" "
android:textSize="15sp"
android:fontFamily="#font/adobearabicregular"
/>
<ImageView
android:id="#+id/imv_refresh2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/tx_state6"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginTop="40dp"
android:padding="10px"
android:src="#drawable/refresh"
/>
<WebView
android:id="#+id/web2"
android:layout_width="76dp"
android:layout_height="76dp"
android:layout_below="#+id/imv_refresh2"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
>
</WebView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="26dp"
android:layout_marginLeft="13dp"
android:layout_marginRight="13dp"
android:layout_marginBottom="12dp"
android:gravity="right"
android:orientation="horizontal">
<TextView
android:id="#+id/txMore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/adobearabicbold"
android:text="مشاهده همه..."
android:textSize="12sp"
/>
<TextView
android:id="#+id/txYHinCityDetail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="3dp"
android:fontFamily="#font/adobearabicbold"
android:text="هر آنچه درمورد قم باید بدانید"
android:textSize="24sp" />
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/rvListYH"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<android.support.v7.widget.RecyclerView
android:id="#+id/rvListBazar"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<ProgressBar
android:id="#+id/progressBar66"
style="#android:style/Widget.Holo.ProgressBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/rv_listcity"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:indeterminate="true"
android:visibility="gone" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</LinearLayout>
How can i do it work?
Thank you
Removing the following line parent tag in file city_detail_act.xml should fix it
android:paddingBottom="65dp"
And add these to your include tag
android:layout_width="match_parent"
android:layout_height="match_parent"
Also, consider using Bottom Nav layout for UI like this.
First remove this:
android:paddingBottom="65dp"
Then your include should be like this:
<include
android:id="#+id/content"
layout="#layout/city_detail_act"
android:layout_width="match_parent"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="#id/tolbar_storyButton"
app:layout_constraintTop_toTopOf="parent" />
I have AppBarLayout inside CoordinatorLayout while scrolling from AppBarLayout area from top to bottom then some time suddenly scrolls up.
here is the result1 result2
Layout :
<?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.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/white"
android:orientation="vertical"
app:elevation="0dp">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/layout_header_title_list_item_listing" />
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_scrollFlags="scroll">
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/imgThumbDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:adjustViewBounds="true"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<cn.jzvd.JZVideoPlayerStandard
android:id="#+id/videoplayerDetails"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="invisible"
app:layout_constraintDimensionRatio="W,1:1.5"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<com.videosgifsimages.smallbang.SmallBangView
android:id="#+id/like_heart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:clickable="false"
android:visibility="invisible"
app:circle_end_color="#00000000"
app:circle_start_color="#00000000"
app:dots_primary_color="#c60d2c"
app:dots_secondary_color="#e9cf0b"
app:layout_constraintBottom_toBottomOf="#+id/videoplayerDetails"
app:layout_constraintEnd_toEndOf="#+id/videoplayerDetails"
app:layout_constraintStart_toStartOf="#+id/videoplayerDetails"
app:layout_constraintTop_toTopOf="#+id/videoplayerDetails">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="#drawable/ic_like_animate" />
</com.videosgifsimages.smallbang.SmallBangView>
</android.support.constraint.ConstraintLayout>
<include
layout="#layout/layout_bottom_list_item_listing"
android:layout_width="match_parent"
android:layout_height="54dp"
app:layout_scrollFlags="scroll" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#f2f2f2"
app:layout_scrollFlags="scroll">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="ad"
android:textColor="#565656"
android:textSize="12sp"
android:textStyle="normal" />
</FrameLayout>
</LinearLayout>
</FrameLayout>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recyclerViewDetails"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_gravity="bottom"
android:background="#ecf0f1"
android:orientation="horizontal"
android:padding="10dp">
<EditText
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/rounded_edittext_post_comment"
android:hint="Comment"
android:inputType="textPersonName"
android:paddingEnd="15dp"
android:paddingStart="15dp" />
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginStart="17dp"
android:background="#drawable/circle_background_post_comment_btn"
android:scaleType="centerInside"
android:src="#drawable/ic_post_comment" />
</LinearLayout>
<View
android:id="#+id/viewDimBgForBottomSheet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#99000000"
android:visibility="gone" />
<include layout="#layout/bottom_sheet" />
</android.support.design.widget.CoordinatorLayout>