I have a Page that contains a navigationDrawer, imageView, two flipperView and a gridView. Earlier only the gridView was scrollable so to make the whole page scrollable I put all the views in a nestedScrollView but now even the gridView is unscrollable. And also the first flipperView doesn't show any flippers, just the plain blue background view is displayed.
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawerLayout"
android:nestedScrollingEnabled="true"
tools:context="com.example.xxx.xxx.MainActivity"
app:layout_behavior="android.support.design.widget.AppBarLayout.ScrollingViewBehaviour">
<android.support.design.widget.NavigationView
android:id="#+id/navView"
android:layout_width="200dp"
android:layout_height="match_parent"
app:menu="#menu/navigation_menu"
android:layout_gravity="start"
app:layout_behavior="android.support.design.widget.AppBarLayout.ScrollingViewBehaviour"
android:alpha="0.4"/>
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
android:overScrollMode="never"
android:clipToPadding="false">
<LinearLayout
android:orientation="vertical"
android:background="#0F0F0F"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent"
tools:context="com.example.xxxx.myapplication.MainActivity"
android:isScrollContainer="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#ff77"
android:layout_marginTop="5dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/banner1"
android:src="#drawable/b1"
android:scaleType="fitXY"
android:layout_marginLeft="0dp"
android:layout_marginRight="0dp"/>
</LinearLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#2252FF"
android:id="#+id/rel1"
android:layout_marginTop="5dp">
<technolifestyle.com.imageslider.FlipperLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/flipper1">
</technolifestyle.com.imageslider.FlipperLayout>
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="5dp"
android:id="#+id/rel2"
android:layout_width="match_parent"
android:layout_height="75dp"
android:background="#2252FF">
<technolifestyle.com.imageslider.FlipperLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/Flipper2">
</technolifestyle.com.imageslider.FlipperLayout>
</RelativeLayout>
<RelativeLayout
android:background="#fff090"
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">
<GridView
android:id="#+id/grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#0f0f0f"
android:numColumns="3"
android:padding="2dp"
android:gravity="center"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth"
android:verticalSpacing="2dp">
</GridView>
</RelativeLayout>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</android.support.v4.widget.DrawerLayout>
ListViews have its own scrollable behaviour. You need to cancel to add this to the GridView and maybe to de FliperLayouts as well.
android:nestedScrollingEnabled="false"
Or by code:
gridView.setNestedScrollingEnabled(false);
Hope it helps!
Related
Problem is I am unable to scroll through my content I have generated through recyclerview and cardview nest inside it as a repeating layout for adapter, but scrolling isn't working by Touch but when I press down keyboard key content is scrolling
<?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:background="#color/bgSec"
tools:context=".MainActivity">
<android.support.v4.widget.DrawerLayout
android:id="#+id/drawer_layout"
android:elevation="50dp"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent">
<include layout="#layout/app_bar"
android:layout_height="match_parent"
android:layout_width="match_parent"/>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_gravity="start"
android:fitsSystemWindows="true"
app:headerLayout="#layout/header_layout"
app:menu="#menu/side_menu"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_gravity="bottom"
android:background="#000"
android:layout_height="150dp">
</LinearLayout>
</android.support.design.widget.NavigationView>
</android.support.v4.widget.DrawerLayout>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_alignParentStart="true"
android:layout_alignParentTop="true"/>
</RelativeLayout>
and card_view.xml is below
<?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_height="wrap_content"
android:layout_width="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/card_view"
android:background="#color/bgWhite"
app:cardElevation="5dp"
android:layout_width="match_parent"
android:layout_margin="10dp"
android:layout_height="300dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="None"
android:id="#+id/category_name"/>
</android.support.v7.widget.CardView>
</RelativeLayout>
Expected to scroll by touch but scrolling by keyboard down arrow key instead
When I open the app only the ListView scroll but the sliding image I made didn't scroll up together.
<?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:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
</android.support.v4.view.ViewPager>
<ListView
android:id="#+id/oneListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_marginTop="261dp" />
</RelativeLayout>
If put the ScrollView within the upper part of ViewPager my app crashed.
screenshot
Using NestedScrollView might work for you. You can use the following code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.NestedScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/test">
<android.support.v4.view.ViewPager
android:id="#+id/view_pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true">
</android.support.v4.view.ViewPager>
<android.support.v7.widget.RecyclerView
android:id="#+id/oneListView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/view_pager">
</android.support.v7.widget.RecyclerView>
</RelativeLayout>
</android.support.v4.widget.NestedScrollView>
I am new in Xamarin. I have problem fixing the Main_Menu.axml layout to my desired layout which is on the link below.How can I put a layout above and my gridview below? I need help in that.
Desired Layout is below
My current Mainmenu.axml code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1"
android:orientation="vertical"
android:focusable="true"
android:focusableInTouchMode="true"
android:background="#drawable/background">
<include
android:id="#+id/toolbar"
layout="#layout/sublayout_Toolbar" />
<android.support.v4.widget.DrawerLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="0.4" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.6">
<GridView
android:id="#+id/mainMenu_GridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:numColumns="2"
android:listSelector="#null"
android:verticalSpacing="0dp"
android:horizontalSpacing="0dp" />
</LinearLayout>
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_height="match_parent"
android:layout_width="wrap_content"
android:layout_gravity="start"
android:background="#color/light_blue" />
</android.support.v4.widget.DrawerLayout>
</LinearLayout>
My current layout as below
In my home screen I want to add the search box with navigation drawer but I am not able to set the non scrollable edittext over scrollview.
Here is my Code
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#ecedf1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp"
>
<EditText
android:layout_width="#dimen/_280sdp"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_height="#dimen/_40sdp"
android:text="fdgsdfhsfhsfghhsfhsfhf"
android:background="#drawable/customedittext"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/viewPagerIndicator"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="#dimen/_180sdp"
android:gravity="center">
<LinearLayout
android:id="#+id/viewPagerCountDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal" />
</RelativeLayout>
<com.information.aanjana.aanjanainformation.NonScrollGridView
android:id="#+id/gv_android"
android:layout_width="#dimen/_299sdp"
android:layout_height="match_parent"
android:horizontalSpacing="8dp"
android:layout_centerHorizontal="true"
android:numColumns="2"
android:paddingLeft="#dimen/_4sdp"
android:paddingRight="#dimen/_4sdp"
android:layout_marginTop="#dimen/_220sdp"
android:verticalSpacing="8dp"/>
</RelativeLayout>
</ScrollView>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="#dimen/_170sdp"
android:layout_gravity="start"
app:menu="#menu/drawer"
/>
</android.support.v4.widget.DrawerLayout>
I want a edittext with navigation drawer which should be sticky and do not scroll with rest of the layout. How can I achive it.
What I want is explained in screenshot below:
Try my below code:
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#ecedf1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp" />
<RelativeLayout
android:id="#+id/viewPagerIndicator"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="#dimen/_180sdp"
android:gravity="center">
<LinearLayout
android:id="#+id/viewPagerCountDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal" />
</RelativeLayout>
<com.information.aanjana.aanjanainformation.NonScrollGridView
android:id="#+id/gv_android"
android:layout_width="#dimen/_299sdp"
android:layout_height="match_parent"
android:horizontalSpacing="8dp"
android:layout_centerHorizontal="true"
android:numColumns="2"
android:paddingLeft="#dimen/_4sdp"
android:paddingRight="#dimen/_4sdp"
android:layout_marginTop="#dimen/_220sdp"
android:verticalSpacing="8dp"/>
</RelativeLayout>
</ScrollView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp"
android:layout_alignParentTop="true"
>
<EditText
android:layout_width="#dimen/_280sdp"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_height="#dimen/_40sdp"
android:text="fdgsdfhsfhsfghhsfhsfhf"
android:background="#drawable/customedittext"/>
</RelativeLayout>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="#dimen/_170sdp"
android:layout_gravity="start"
app:menu="#menu/drawer"
/>
</android.support.v4.widget.DrawerLayout>
Here Only thing which I have changed is kept the editText outside the scrollView.
Why don't you try to put it out outside the ScrollView. Then just overlay it with a RelativeLayout and the gravity set to top. I can't run it now but in xml should look like something like this
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
android:background="#ecedf1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v4.view.ViewPager xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/viewpager"
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp" />
<RelativeLayout
android:id="#+id/viewPagerIndicator"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_marginTop="#dimen/_180sdp"
android:gravity="center">
<LinearLayout
android:id="#+id/viewPagerCountDots"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:gravity="center"
android:orientation="horizontal" />
</RelativeLayout>
<com.information.aanjana.aanjanainformation.NonScrollGridView
android:id="#+id/gv_android"
android:layout_width="#dimen/_299sdp"
android:layout_height="match_parent"
android:horizontalSpacing="8dp"
android:layout_centerHorizontal="true"
android:numColumns="2"
android:paddingLeft="#dimen/_4sdp"
android:paddingRight="#dimen/_4sdp"
android:layout_marginTop="#dimen/_220sdp"
android:verticalSpacing="8dp"/>
</RelativeLayout>
</ScrollView>
<!-- Here we add the layout outside the ScrollView -->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="#dimen/_200sdp"
android:gravity="top"> <!-- GRAVITY ADJUST -->
<EditText
android:layout_width="#dimen/_280sdp"
android:layout_centerHorizontal="true"
android:layout_marginTop="#dimen/_10sdp"
android:layout_height="#dimen/_40sdp"
android:text="fdgsdfhsfhsfghhsfhsfhf"
android:background="#drawable/customedittext"/>
</RelativeLayout>
<android.support.design.widget.NavigationView
android:id="#+id/navigation_view"
android:layout_height="match_parent"
android:layout_width="#dimen/_170sdp"
android:layout_gravity="start"
app:menu="#menu/drawer"
/>
</android.support.v4.widget.DrawerLayout>
Hopefully, it runs smoothly and turns out helpful.
Couldn't find a more appropriate title but my problem is the following. I have a LinearLayout that contains another LinearLayout and a fragment. I also want to add the toolbar but when I do so, then I only see the toolbar and the other screen is just white.
Here is the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:context="xeniasis.mymarket.MainActivity">
<include
android:id="#+id/toolbar"
layout="#layout/toolbar" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:baselineAligned="false"
android:weightSum="4">
<LinearLayout
android:id="#+id/categories_layout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:paddingRight="20dp">
<ExpandableListView
android:id="#+id/categories_listView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
<fragment
android:id="#+id/mainPane"
android:name="xeniasis.mymarket.Products"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="3"
tools:layout="#layout/activity_main" />
</LinearLayout>
</LinearLayout>
Toolbar:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:elevation="4dp"
android:padding="5dp"
android:theme="#style/ToolbarTheme" />
And the fragment layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="xeniasis.mymarket.MainActivity">
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/swipeRefreshContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="#dimen/activity_vertical_margin">
<GridView
android:id="#+id/productsGridview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:numColumns="3"></GridView>
</android.support.v4.widget.SwipeRefreshLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="8dp"
android:clickable="true"
android:elevation="5dp"
android:src="#android:drawable/ic_menu_search" />
</android.support.design.widget.CoordinatorLayout>
</LinearLayout>
This only happens when I have a fragment, cause I previously had the same xml with a static layout where the fragment is now.
The problem is that you used a LinearLayout with
android:orientation="horizontal"
and since the toolbar has match_parent as width it occupies all the screen.
Try to use
android:orientation="vertical"
in the root layout