Here is my layout. The problem is that either the PageViewer contents are visible and nothing else. If I see PageViewer to gone than I see everything above it. Also tried root layout as frame layout but it does not help. Main thing is only the view pager is visible. What I want is 2/3 ViewPager contents which contains data, and above some header material that is 1/3. I don't want to use weights as the upper part is already sized correctly. I just want to guarantee that both the top and pageviewer display properly. Is it a characteristic of pageviewers that they switch everything? or can they not be applied below another element?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mHeaderHeader"
android:visibility="visible"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include
android:id="#+id/myInclude"
layout="#layout/myInclude_layout" />
<include
android:id="#+id/myInclude2r"
layout="#layout/myInclude2" />
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</FrameLayout>
<include
android:id="#+id/myInclude3"
layout="#layout/myinclude3layout" />
<ImageView
android:id="#+id/myImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<android.support.v4.view.ViewPager
android:id="#+id/myViewPager"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<include layout="#layout/myinclude4" />
</LinearLayout>
You can try something like this:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="match_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/mHeaderHeader"
android:visibility="visible"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:orientation="vertical">
<include
android:id="#+id/myInclude"
layout="#layout/myInclude_layout" />
<include
android:id="#+id/myInclude2r"
layout="#layout/myInclude2" />
<include
android:id="#+id/myInclude3"
layout="#layout/myinclude3layout" />
<ImageView
android:id="#+id/myImageView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
<include layout="#layout/myinclude4"
android:id="#+id/myinclude4" />
<android.support.v4.view.ViewPager
android:id="#+id/myViewPager"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBelow="#id/mHeaderHeader"
android:layout_alignAbove="#id/myinclude4" />
</RelativeLayout>
I suppose that ViewPager takes all space, so I placed it below header and above footer using RelativeLayout
Related
I'm trying to add the image view but when I do it has so much space between the top and bottom of the image. I'm using a bottom navigation with fragments. I would like to make the image close to the top with the space. What am I doing wrong with this layout?
Main Activity
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:design="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="com.example.android.gershpark.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/main_image"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:contentDescription="main image"
android:src="#drawable/fb_img_1497698892826" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/frame_layout"
android:layout_below="#id/main_image"
/>
<View
android:id="#+id/view"
android:layout_width="match_parent"
android:layout_height="8dp"
android:background="#drawable/shadow"
android:layout_above="#+id/bot_nav">
</View>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bot_nav"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_alignParentBottom="true"
android:layout_height="wrap_content"
android:background="#android:color/holo_blue_light"
design:itemIconTint='#f8f8f8'
design:menu='#menu/bot_menu'
/>
</RelativeLayout>
</android.support.design.widget.CoordinatorLayout>
Home Fragment
<FrameLayout 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"
tools:context="com.example.android.gershpark.HomeFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Home"/>
</FrameLayout>
Looks like by adding the following it removed the spacing that was there.
android:adjustViewBounds="true"
I would like to ask how can i display included layout and listview positioned under the included in onde view.
Layout:
<android.support.v4.widget.SwipeRefreshLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.TransactionsActivity">
<include
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_alignParentTop="true"
layout="#layout/preloader" />
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/list"
/>
</android.support.v4.widget.SwipeRefreshLayout>
In the preview is displayed only the included layout, but lisview below is not displayed.
Many thanks for any advice.
Since SwipeRefreshLayout accept only one child. Wrap it inside LinearLayout or RelativeLayout.
<android.support.v4.widget.SwipeRefreshLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/swipeContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".activity.TransactionsActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include
layout="#layout/preloader"
android:layout_width="fill_parent"
android:layout_height="10dp"
android:layout_alignParentTop="true" />
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
Best Of Luck.
I have a linearView with cardViews and some other elements.
The view with all it's elements is scrallable.
I'm trying to add a fixed toolbar in the bottom of the screen by wrapping everything in RelativeView and using alignParentBottom on the layout of my toolbar, but The toolbar is added to the bottom of the scrallable page ( you need to scroll all the way down to see it.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/fragment_poi_detail_main_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<include layout="#layout/toolbar_image" />
<View
android:id="#+id/fragment_poi_detail_line"
android:layout_width="match_parent"
android:layout_height="#dimen/toolbar_shadow_height"
android:background="#drawable/shape_shadow"/>
<include
layout="#layout/fragment_poi_detail_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/fragment_poi_detail_card_margin_vertical_first"
android:layout_marginBottom="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginLeft="#dimen/fragment_poi_detail_card_margin_horizontal_first"
android:layout_marginRight="#dimen/fragment_poi_detail_card_margin_horizontal_last"/>
<include
layout="#layout/fragment_poi_detail_content_info"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/fragment_poi_detail_card_margin_vertical_first"
android:layout_marginBottom="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginLeft="#dimen/fragment_poi_detail_card_margin_horizontal_first"
android:layout_marginRight="#dimen/fragment_poi_detail_card_margin_horizontal_last"/>
<include
layout="#layout/fragment_poi_detail_content_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginBottom="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginLeft="#dimen/fragment_poi_detail_card_margin_horizontal_first"
android:layout_marginRight="#dimen/fragment_poi_detail_card_margin_horizontal_last" />
<include
layout="#layout/fragment_poi_detail_content_map"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginBottom="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginLeft="#dimen/fragment_poi_detail_card_margin_horizontal_first"
android:layout_marginRight="#dimen/fragment_poi_detail_card_margin_horizontal_last" />
<include
layout="#layout/fragment_poi_detail_content_description"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/fragment_poi_detail_card_margin_vertical"
android:layout_marginBottom="#dimen/fragment_poi_detail_card_margin_vertical_last"
android:layout_marginLeft="#dimen/fragment_poi_detail_card_margin_horizontal_first"
android:layout_marginRight="#dimen/fragment_poi_detail_card_margin_horizontal_last" />
</LinearLayout>
<include layout="#layout/fragment_poi_detail_bottom_action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
>
</include>
</RelativeLayout>
What am I doing wrong?
Thanks for your help :)
This is the view scrolled to bottom, and the bar in the bottom of the view.
I am using ActionBarSherlock for tabs in android
main_fragment_desc_list_view.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<include layout="#layout/screen_parent_topbar" />
<android.support.v4.app.FragmentTabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.app.FragmentTabHost>
<include layout="#layout/screen_parent_bottombar" />
</LinearLayout>
What i am having trouble with ?
Even though i have added the code <include layout="#layout/screen_parent_bottombar" /> it is not shown in the screen when i execute the code
What changes should i need to make here so that i am able to get my bottom layout included at the bottom ?
Your android.support.v4.app.FragmentTabHost has a height of MATCH_PARENT and therefore the layout at the bottom will not appear.
One alternative would be using a RelativeLayout to create the header/content/footer layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<include android:id="#+id/header"
android:layout_alignParentTop="true"
layout="#layout/screen_parent_topbar" />
<include android:id="#+id/footer"
android:layout_alignParentBottom="true"
layout="#layout/screen_parent_bottombar" />
<android.support.v4.app.FragmentTabHost
android:layout_below="#id/header"
android:layout_above="#id/footer"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<FrameLayout
android:id="#+id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.app.FragmentTabHost>
</RelativeLayout>
I know this is a bit odd but bear with me.
I have a custom view, that extends TabHost and inflates a XML.
It includes several views, it is aligned to bottom and everything works great.
The problem is when I put the TabHost in a different activity, where I don't want to see any of the TabHost views. Only the TabHost tabs on top of the activity layout. Basically, I want the TabHost to be there as a disabled bottom bar.
here's the TabHost XML (which works great and aligned to bottom, as long as I toggle between one of the custom views):
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
>
<CustomView#1
android:id="#+id/tab_watch_me"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<CustomView#2
android:id="#+id/tab_messages"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<CustomView#3
android:id="#+id/tab_search_results"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<CustomView#4
android:id="#+id/tab_my_profile"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<CustomView#5
android:id="#+id/tab_user_profile"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</FrameLayout>
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</LinearLayout>
</TabHost>
Here's the activity XML (the one that I don't want the tabhost views to be shown, only to align the tabhost buttons to the bottom):
<?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" >
<customview.HeaderView
android:id="#+id/header_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
**//Notice that I don't want to show any of the customViews the tabhost hold. only the tabhost tabs/buttons**
<customview.MyTabHost
android:id="#+id/settings_tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
Let me know if you need more code in order to help!
Thank you!
My RelativeLayout solution in case this helps anyone. I'm still looking for a better solution if anyone has to offer.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<customview.HeaderView
android:id="#+id/header_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true" />
<Any other view
android:layout_below="#+id/header_view"
/>
<customview.MyTabHost
android:id="#+id/settings_tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true" />
</RelativeLayout>