I have a screen with button "Next" over keyboard. I added scroll. If keyboard open and space is not enough we need to use scroll. But with a little space scroll does not appear, and button are squeezes.
http://meson.ad-l.ink/8bXzYgJQW/thumb.png
http://polariton.ad-l.ink/7XGrCsMb4/thumb.png
In manifest
<activity
android:name=".activity.register.RegisterPhoneActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="stateVisible|adjustResize"
/>
activity_register_phone.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical">
<include layout="#layout/w_toolbar" />
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="6dp"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
android:fillViewport="true"
android:scrollbars="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="top"
>
<com.devspark.robototextview.widget.RobotoTextView
android:id="#+id/badge"
android:layout_width="#dimen/size_badge"
android:layout_height="#dimen/size_badge"
android:textSize="#dimen/text.16"
android:background="#drawable/circle_tv"
android:gravity="center"
android:text="1"
app:typeface="roboto_regular"
/>
<com.devspark.robototextview.widget.RobotoTextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/margin_10"
android:textSize="#dimen/text.26"
android:text="#string/enter_your_number"
android:layout_centerVertical="true"
android:layout_toRightOf="#+id/badge"
app:typeface="roboto_light"
/>
</RelativeLayout>
<com.devspark.robototextview.widget.RobotoTextView
android:id="#+id/description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_20"
android:gravity="left"
android:textSize="#dimen/text.15"
android:textColor="#color/secondary_text_color"
android:text="#string/register_phone_description"
app:typeface="roboto_regular"
/>
<com.devspark.robototextview.widget.RobotoEditText
android:id="#+id/et_username_phone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:textSize="#dimen/text.24"
android:layout_marginTop="#dimen/margin_22"
android:background="#drawable/edt_bg_selector"
app:typeface="roboto_regular"
/>
<com.devspark.robototextview.widget.RobotoTextView
android:id="#+id/content_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_6"
android:layout_marginLeft="#dimen/margin_15"
android:layout_marginRight="#dimen/margin_15"
android:gravity="center"
android:textColor="#color/url_grey_text_color"
android:textSize="#dimen/text.11"
app:typeface="roboto_regular"
tools:text="#string/register_phone_content_info"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.devspark.robototextview.widget.RobotoButton
android:id="#+id/btn_next"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/margin_16"
android:layout_gravity="bottom"
android:text="#string/btn_register_next_step"
android:textSize="#dimen/text.15"
android:enabled="false"
style="#style/ButtonStyle"
app:typeface="roboto_medium"
/>
</FrameLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
Remove adjustResize
then make your LinearLayout height inside your ScrollView wrap_content, then it wont squeeze.
Related
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'm trying to add a few icons for a custom bottom navigation bar in my layout, and when I tried to add them, the NestedScrollView that occupies most of the screen has become very slow, the scrolling doesn't go smoothly with the touch gestures anymore just because of adding a few icons.
I don't understand this behavior of the NestedScrollViews. It contains a recyclerview by the way. I've put up my layout code here. The bottom_layout, which contains a view group with four icon-sized images causes the issue. If I have 1 or 2 images instead, there is no issue at all.
Edit: If possible, I would like to have some advice on a good way to load a layout which has lists as children of a scrolling view.
XML:
<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:background="#ffffff"
tools:context=".activities.PlacesActivity">
<LinearLayout
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:layout_marginTop="22sp"
android:background="#555555"
android:orientation="horizontal">
<TextView
android:id="#+id/place_toolbar_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_vertical"
android:layout_marginLeft="10dp"
android:layout_weight="0.2"
android:gravity="center_vertical"
android:textColor="#f4e92c"
android:textSize="21sp" />
<!-- android:text="Cubbon Park" for the above textview-->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.9"
android:gravity="center">
<ImageView
android:id="#+id/places_profile_button"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center"
android:layout_marginLeft="12dp"
android:layout_marginTop="4sp"
android:padding="5dp"
android:src="#drawable/profile3x" />
</LinearLayout>
</LinearLayout>
<android.support.v4.widget.NestedScrollView
android:id="#+id/scrollview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#id/bottom_layout"
android:layout_below="#id/toolbar"
android:fillViewport="true"
app:layout_anchor="#id/toolbar"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:descendantFocusability="blocksDescendants"
android:orientation="vertical">
<ImageView
android:id="#+id/image_place_header"
android:layout_width="match_parent"
android:layout_height="200dp"
android:scaleType="centerCrop"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="#ececef" />
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/map_card_place"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center">
<LinearLayout
android:id="#+id/map_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/map_icon"
android:layout_width="30dp"
android:layout_height="30dp"
android:src="#drawable/location3x" />
<TextView
android:id="#+id/labelOnMap"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:text="Point of Interest"
android:textColor="#757575"
android:textSize="20sp" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com
/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.testapp.android.WorkaroundMapFragment"
android:layout_width="match_parent"
android:layout_height="170dp"
tools:context="com.example.googlemap.MapsActivity" />
</LinearLayout>
</android.support.v7.widget.CardView>
<!--recyclerview containing all the content-->
<android.support.v7.widget.RecyclerView
android:id="#+id/metadata"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
<include
android:id="#+id/bottom_layout"
layout="#layout/bottom_bar"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="40dp" />
<ImageButton
android:id="#+id/fab_main"
android:layout_width="62dp"
android:layout_height="62dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="?attr/selectableItemBackgroundBorderless"
android:scaleType="fitCenter"
android:src="#drawable/btn_scan_large" />
</RelativeLayout>
I found out the solution to remove sluggishness was to just place the images in drawable-nodpi folder.
found this answer here helpful:
https://stackoverflow.com/a/51960548/10165076
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>
I would like to add 3 boxes on top of the Google Map to hold some text starting from the bottom stacked on top of each other.
Note: <Button> is what I'm using to test out if anything will appear on the google maps. It turns out that nothing appears.
Am I on the right track to achieving what I want? What should I change?
Here's activity_maps.xml:
<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="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="#+id/searchBar"
android:layout_width="289dp"
android:layout_height="wrap_content" />
<Button
android:id="#+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="onSearch"
android:text="SEARCH" />
</LinearLayout>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mancj.example.MapsActivity">
</fragment>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_marginBottom="20dp"
/>
</LinearLayout>
Alright, try this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.mancj.example.MapsActivity">
</fragment>
<LinearLayout
android:background="#android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
<EditText
android:hint="Search"
android:id="#+id/searchBar"
android:layout_width="289dp"
android:layout_height="wrap_content" />
<Button
android:id="#+id/searchButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:onClick="onSearch"
android:text="SEARCH" />
</LinearLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:id="#+id/button2"/>
</RelativeLayout>
I want to replicate the Navigation Drawer similar to that of the LinkedIn App below:
Note that the message, notification, and the settings buttons at the top are persistent and are not part of the scrollable list.
I've followed the official Android tutorial for Navigation Drawer as well as numerous other tutorials that simply do not provide additional light into how I can achieve this.
The best I could think of was to add 3 ImageButtons to the header layout of the Navigation Drawer template in Android Studio 2.1.1.
EDIT: As per Prat's and a few others advice, I've included an additional header layout just before the drawer that contains the 3 buttons, but no matter the z-ordering of the layouts within the xml, it seems to hide behind the drawer. See image illustration below:
Below are the layout files:
header.xml (contains the 3 buttons)
<?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:gravity="right"
android:background="#111">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
</LinearLayout>
nav_header_main.xml (default generated header)
<?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:gravity="right"
android:background="#111">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
</LinearLayout>
activity_main.xml
<?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"
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"
tools:openDrawer="start">
<include
layout="#layout/app_bar_main"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#fff">
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="start"
android:fitsSystemWindows="false"
app:headerLayout="#layout/nav_header_main"
app:menu="#menu/activity_main_drawer" />
<include
android:id="#+id/header"
layout="#layout/header"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true" />
</RelativeLayout>
</android.support.v4.widget.DrawerLayout>
Try to do like this :
header.xml(top most layout where you have 3 images)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<ImageButton
android:id="#+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:src="#drawable/ic_menu_manage" />
</LinearLayout>
</LinearLayout>
nav_header_main( default android header)
<?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="#dimen/nav_header_height"
android:background="#drawable/side_nav_bar"
android:gravity="bottom"
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"
android:theme="#style/ThemeOverlay.AppCompat.Dark">
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:src="#android:drawable/sym_def_app_icon" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/nav_header_vertical_spacing"
android:text="Android Studio"
android:textAppearance="#style/TextAppearance.AppCompat.Body1" />
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="android.studio#android.com" />
</LinearLayout>
then finally the main layout showing
header(top)
nav_main_header
listview
<!-- The main content view -->
<FrameLayout
android:id="#+id/flFragmentContainer"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<!-- The navigation drawer -->
<RelativeLayout
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="#111">
<include android:id="#+id/header"
layout="#layout/header"
android:layout_width="fill_parent"
android:layout_alignParentTop="true"
android:layout_height="100dp"/>
<include android:id="#+id/header2"
layout="#layout/nav_header_main"
android:layout_width="fill_parent"
android:layout_below="#id/header"
android:layout_height="100dp"/>
<ListView
android:id="#+id/lvDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:choiceMode="singleChoice"
android:layout_below="#id/header2"
android:divider="#android:color/transparent"
android:dividerHeight="0dp" />
</RelativeLayout>
Use recyclerview with adapter for this. You can implement any structure of custom views for items.