I have to put a drawer layout for my app, hence I have finished the layout and functions in an activity.Now, I'm unable to use Fragments.How can I set the drawer using the menu function in the activity?Please help me.This is my main layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"`enter code here`
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="2" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="0.2"
android:background="#color/MediumSeaGreen"
android:orientation="horizontal"
android:weightSum="1">
<ImageView
android:id="#+id/notification_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.85"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_action_overflow" />
<TextView
android:id="#+id/mytrip_title"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="0.25"
android:gravity="center"
android:text="#string/Notification"
android:textSize="#dimen/mytrip_title"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1.8"
android:orientation="horizontal"
android:weightSum="1" >
<ListView
android:id="#+id/notification_list_view"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</ListView>
</LinearLayout>
</LinearLayout>
And this the layout what i have designed for drawer,
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#00000000"
android:paddingRight="10dp"
android:layout_weight="8"
android:layout_marginLeft="10dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/menu_home_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_home_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Home"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_Trips_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_trips_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Trips"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_notification_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_notification_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Notification"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_Settings_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_settings_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Settings"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_profile_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_profile_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Profile"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/gray" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<ImageView
android:id="#+id/menu_friends_icon"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="#dimen/menu_icon_padding"
android:src="#drawable/ic_launcher"
android:gravity="center" />
<TextView
android:layout_marginLeft="10dp"
android:id="#+id/menu_friends_text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="Friends"
android:textSize="#dimen/mytrip_title" />
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"`enter code here`
android:background="#color/gray" />
</LinearLayout>
while clicking the notification_settings imageview in the main layout i have to view the below designed layout for drawer function please help me
Try this,
replace your current activity layout with this,
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_drawer"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:id="#+id/content_frame"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
// put your existing widgets here
</FrameLayout>
<ListView
android:id="#+id/drawer_menu"
android:layout_width="define your width"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:layout_weight="1"
/>
Instantiate drawer layout, your menu list, action bar and toggle in your activity.
Define suitable row layout for the list and set the data. You can easily find sample code from here.
Related
first : what is official name of the black bar at bottom of the screen ?
second :
i have two layout merged together problem is part of my second layout will hide behind this bar there is red bar behind this but is hidden this problem is in those devices has this bar
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<include layout="#layout/content_opina" />
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_marginRight="16dp"
android:layout_marginBottom="52dp"
android:src="#drawable/ic_add_24dp" />
<?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:paddingTop="5dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="opina.android.ri4n.sir.opina.Opina"
tools:showIn="#layout/activity_opina">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/shadow"
android:layout_margin="5dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:padding="5dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="60dp">
<ImageView
android:layout_width="40dp"
android:layout_height="40dp"
android:id="#+id/avator"
android:layout_margin="10dp" />
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.8">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="20dp"
android:hapticFeedbackEnabled="false"
android:layout_marginTop="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Username ..."
android:id="#+id/username"
android:textColor="#000000"
android:gravity="center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="15dp"
>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="Question ... "
android:id="#+id/question"
android:textColor="#757575"
android:gravity="center_vertical" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.2">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="2W"
android:id="#+id/textView"
android:gravity="center" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:paddingRight="5dp"
android:paddingLeft="5dp">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="#000000"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="There is no such attribute in Android, to show a shadow. But possible ways to do it ... Have a 9-patch image with a shadow and set it as the background to your"
android:id="#+id/textView2" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="40dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="70dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView"
android:src="#drawable/ic_favorite_24dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="124"
android:textSize="12dp"
android:id="#+id/textView3"
android:gravity="left|center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="70dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView2"
android:src="#drawable/gesture"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="124"
android:textSize="12dp"
android:id="#+id/textView4"
android:gravity="left|center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="70dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView3"
android:src="#drawable/ic_comment_24dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="124"
android:textSize="12dp"
android:id="#+id/textView5"
android:gravity="left|center_vertical" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="70dp"
android:layout_height="match_parent">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:id="#+id/imageView4"
android:src="#drawable/ic_visibility_24dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="5dp" />
<TextView
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="124"
android:textSize="12dp"
android:id="#+id/textView6"
android:gravity="left|center_vertical" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:background="#drawable/bshadow"></LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="45dp"
android:orientation="horizontal"
android:background="#d2d2d2">
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView10"
android:layout_gravity="center"
android:src="#drawable/ic_home_24dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView11"
android:layout_gravity="center"
android:src="#drawable/ic_dns_24dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView12"
android:layout_gravity="center"
android:src="#drawable/ic_notifications_24dp" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:gravity="center">
<ImageView
android:layout_width="25dp"
android:layout_height="25dp"
android:id="#+id/imageView13"
android:layout_gravity="center"
android:src="#drawable/ic_people_24dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Android Navigation Buttons. You can also able to change it's color or hide/show them
The Name of this bar is "Navigation Bar"
I am unable to place a layout at the bottom after a scroll view. Please help.
This is my code:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="10dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdgeLength="0dp"
android:overScrollMode="never"
android:scrollbars="horizontal" />
<LinearLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="30dp"
android:orientation="horizontal"
android:gravity="bottom">
<LinearLayout
android:id="#+id/linear_call"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:padding="8dp"
android:background="#drawable/list_selector">
<ImageView
android:id="#+id/btn_phone_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/call_us_tab"/>
<TextView
android:id="#+id/call"
android:textColor="#android:color/white"
android:text="Call Us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:padding="8dp"
android:background="#drawable/list_selector"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/message_tab"
/>
<TextView
android:id="#+id/msg"
android:textColor="#android:color/white"
android:text="Message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/list_selector"
android:padding="8dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/share_tab"/>
<TextView
android:id="#+id/share"
android:textColor="#android:color/white"
android:text="Share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdgeLength="0dp"
android:padding="5dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none"
android:layout_above="#+id/bottom">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/tv_name_detail_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"
android:layout_marginTop="5dp"/>
<TextView
android:id="#+id/tv_map"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Map"
android:singleLine="true"
android:textStyle="bold"
android:layout_marginTop="5dp"/>
</RelativeLayout>
<TextView
android:id="#+id/tv_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RatingBar
android:layout_marginTop="2dp"
android:id="#+id/rating_bar_pro_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
style="#style/foodRatingBar"/>
<TextView
android:id="#+id/tv_nearby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp" />
<TextView
android:layout_marginTop="5dp"
android:id="#+id/tv_specialization"
android:text="Specialization: "
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<ListView
android:id="#+id/list_specialization"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:layout_marginTop="5dp"
android:id="#+id/tv_education"
android:text="Education:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ListView
android:id="#+id/list_education"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:id="#+id/tv_experiences"
android:layout_marginTop="5dp"
android:text="Experiences:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ListView
android:id="#+id/list_experience"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<!-- The navigation drawer -->
<ListView android:id="#+id/left_drawer"
android:layout_width="260dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#5488B8"
android:dividerHeight="1dp"
android:background="#00427F"
android:listSelector="#drawable/list_selector"
/>
</android.support.v4.widget.DrawerLayout>
Try like this, this will fix your problem.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:fadingEdgeLength="0dp"
android:overScrollMode="never"
android:scrollbars="horizontal" />
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/bottom"
android:layout_below="#+id/my_recycler_view"
android:fadingEdgeLength="0dp"
android:fillViewport="true"
android:overScrollMode="never"
android:padding="5dp"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="bottom"
android:orientation="horizontal">
</LinearLayout>
</RelativeLayout>
Use root layout as RelativeLayout and the view you want to align bottom that's add this line:
android:layout_alignParentBottom="true"
This will solve your issue.
Try this and give your scroll view any variable size rather than wrap_content
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdgeLength="0dp"
android:overScrollMode="never"
android:scrollbars="horizontal" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:fadingEdgeLength="0dp"
android:padding="5dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tv_name_detail_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"
android:layout_marginTop="5dp"
/>
<TextView
android:id="#+id/tv_address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<RatingBar
android:layout_marginTop="2dp"
android:id="#+id/rating_bar_pro_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
style="#style/foodRatingBar"
/>
<TextView
android:id="#+id/tv_nearby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
/>
<TextView
android:layout_marginTop="5dp"
android:id="#+id/tv_specialization"
android:text="Specialization: "
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_specialization"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:layout_marginTop="5dp"
android:id="#+id/tv_education"
android:text="Education:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_education"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:id="#+id/tv_experiences"
android:layout_marginTop="5dp"
android:text="Experiences:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_experience"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
>
<LinearLayout
android:id="#+id/linear_call"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:padding="8dp"
android:background="#drawable/list_selector">
<ImageView
android:id="#+id/btn_phone_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/call_us_tab"/>
<TextView
android:id="#+id/call"
android:textColor="#android:color/white"
android:text="Call Us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:padding="8dp"
android:background="#drawable/list_selector"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/message_tab"
/>
<TextView
android:id="#+id/msg"
android:textColor="#android:color/white"
android:text="Message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="33"
android:orientation="vertical"
android:gravity="center"
android:background="#drawable/list_selector"
android:padding="8dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/share_tab"/>
<TextView
android:id="#+id/share"
android:textColor="#android:color/white"
android:text="Share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
You need to use RelativeLayout instead of LinearLayout at parent and then you can place items up and down to each other like
which view you want below to another view you can use this
android:layout_below="#+id/yourview"
and for view you want above to other you can use this
android:layout_above="#+id/yourview"
here is a sample
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:id="#+id/main"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView">
<!-- some stuff in here -->
</LinearLayout>
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</RelativeLayout>
Hope it helps
try this hopefully this is what you wanted
<?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=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fadingEdgeLength="0dp"
android:overScrollMode="never"
android:scrollbars="horizontal"
/>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="220dp"
android:fadingEdgeLength="0dp"
android:padding="5dp"
android:fillViewport="true"
android:overScrollMode="never"
android:scrollbars="none">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tv_name_detail_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:textStyle="bold"
android:layout_marginTop="5dp"
android:text="Name"/>
<TextView
android:id="#+id/tv_address"
android:text="address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<RatingBar
android:layout_marginTop="2dp"
android:id="#+id/rating_bar_pro_detail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
/>
<TextView
android:id="#+id/tv_nearby"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
/>
<TextView
android:layout_marginTop="5dp"
android:id="#+id/tv_specialization"
android:text="Specialization: "
android:textStyle="bold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_specialization"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:layout_marginTop="5dp"
android:id="#+id/tv_education"
android:text="Education:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_education"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<TextView
android:textStyle="bold"
android:id="#+id/tv_experiences"
android:layout_marginTop="5dp"
android:text="Experiences:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<ListView
android:layout_marginTop="5dp"
android:id="#+id/list_experience"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:weightSum="5"
>
<LinearLayout
android:layout_weight="2"
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom"
android:weightSum="3"
>
<LinearLayout
android:id="#+id/linear_call"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
android:weightSum="3"
android:background="#000000">
<ImageView
android:id="#+id/btn_phone_main"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/name_top"
android:layout_weight="2"
/>
<TextView
android:id="#+id/call"
android:textColor="#android:color/white"
android:text="Call Us"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_message"
android:layout_width="0dp"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
android:weightSum="2"
android:layout_weight="1"
android:background="#000000"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/name_top"
android:layout_weight="1"
/>
<TextView
android:id="#+id/msg"
android:textColor="#android:color/white"
android:text="Message"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<View
android:layout_width="1dp"
android:layout_height="fill_parent"
android:background="#5488B8" />
<LinearLayout
android:id="#+id/linear_share"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center"
android:background="#000000"
android:weightSum="2"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/name_top"
android:layout_weight="1"
/>
<TextView
android:id="#+id/share"
android:textColor="#android:color/white"
android:text="Share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
</LinearLayout>
<!-- The navigation drawer -->
<ListView
android:layout_weight="3"
android:id="#+id/left_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:divider="#5488B8"
android:dividerHeight="1dp"
android:background="#00427F"
android:listSelector="#898989"
/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Please update version of a recyclerview library in gradle file :
compile 'com.android.support:recyclerview-v7:23.2.1'
It should solve your issue.
Due to this issue, wrap_content not used to work on recyclerview before this version.
I have problem with my Header I want include all, because I want a footer static.
I try show in :
screens 3.7 show correctly
Screen > 4.0 show incorrectly
My adapter (Only put header full with footer)
if (viewType == TYPE_HEADER) {
View v = LayoutInflater.from(parent.getContext()).inflate(R.layout.header,parent,false); //Inflating the layout
ViewHolder vhHeader = new ViewHolder(v,viewType,context); //Creating ViewHolder and passing the object of type view
return vhHeader; //returning the object created
}
My XML Header.xml :
<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" tools:context="com.onpocket.alcover.Fragment_0_6"
android:orientation="vertical">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="178dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#drawable/contenedor_img_2_1_6_3"
android:id="#+id/l1">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.3" >
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/barra_lateral_img_0_1"
android:layout_marginLeft="16dp"
android:layout_marginTop="38dp"
android:id="#+id/circleView"
android:adjustViewBounds="false" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.9"
android:background="#af000000"
android:gravity="center_vertical"
android:focusableInTouchMode="false"
android:id="#+id/l3"
android:focusable="false">
<LinearLayout
android:orientation="horizontal"
android:layout_width="15dp"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="text"
android:textSize="14sp"
android:textStyle="bold"
android:id="#+id/name"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="text"
android:id="#+id/email"
android:textColor="#ffffffff" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollView2" >
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView6"
android:src="#drawable/barra_lateral_img_0_2"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_inicio"
android:id="#+id/textView14"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView7"
android:src="#drawable/barra_lateral_img_0_3"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_idiomas"
android:id="#+id/textView15"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="8dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView8"
android:src="#drawable/barra_lateral_img_0_4"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_contacto"
android:id="#+id/textView16"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="10dp"
android:paddingBottom="8dp" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.75" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/imageView9"
android:src="#drawable/barra_lateral_img_0_5"
android:adjustViewBounds="true" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1.3" />
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.2"
android:gravity="center_vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/lateral_notificaciones"
android:id="#+id/textView17"
android:textColor="#010001" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/color_0_0"
android:layout_marginBottom="10dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="60dp"
android:id="#+id/linearLayout10" >
<LinearLayout
android:orientation="horizontal"
android:layout_width="10dp"
android:layout_height="match_parent"></LinearLayout>
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton6"
android:src="#drawable/barra_lateral_img_0_6"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="facebook"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton7"
android:src="#drawable/barra_lateral_img_0_7"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="twitter"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton8"
android:src="#drawable/barra_lateral_img_0_8"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="linkedin"
android:onClick="selectItem" />
<ImageButton
android:layout_width="32dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton9"
android:src="#drawable/barra_lateral_img_0_9"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="12dp"
android:tag="blog"
android:onClick="selectItem" />
<ImageButton
android:layout_width="36dp"
android:layout_height="wrap_content"
android:id="#+id/imageButton10"
android:layout_weight="1"
android:background="#null"
android:scaleType="fitCenter"
android:layout_margin="5dp"
android:tag="youtube"
android:onClick="selectItem" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<!--
<?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="178dp"
android:orientation="vertical"
android:weightSum="1"
android:background="#drawable/contenedor_img_2_1_6_3" android:scaleType="centerCrop">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:orientation="vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="false"
android:layout_alignParentStart="true"
android:background="#color/opacity"
android:gravity="center_vertical">
<TextView
android:id="#+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:textColor="#ffffff"
android:text="Akash Bangad"
android:textSize="14sp"
android:textStyle="bold"
/>
<!– android:background="#7f000000"
android:singleLine="false"
android:paddingLeft="5dp"
android:paddingTop="5dp"
android:paddingRight="15dp"
android:paddingBottom="5dp"–>
<TextView
android:id="#+id/email"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="inicio_texto_empresa"
android:textColor="#ffffffff"
android:layout_marginLeft="16dp"
/>
</LinearLayout>
<de.hdodenhof.circleimageview.CircleImageView
android:layout_width="70dp"
android:layout_height="70dp"
android:src="#drawable/barra_lateral_img_0_1"
android:layout_marginLeft="16dp"
android:layout_marginTop="38dp"
android:id="#+id/circleView"
android:adjustViewBounds="false" />
</RelativeLayout>-->
Try to set the weight of the middle Linearlayout to 1 and its height to 0dp. So only your header and your footer have a fixed height and the scrollview will use the remaining space.
As I know, the list view support add footer view, so you can add a custom footer R.layout.drawer_footer view using listview object as below code
View footerView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.drawer_footer, expandableListView, false);
TextView footer = footerView.findViewById(R.id.id_footer_wta_version_information);
expandableListView.addFooterView(footerView);
In my case, I use expandableListView the expandableListView is the same as listView. Hope this way help you
I' am trying to achieve sth like this:
But the ListView is overlaps my bottom bar. What is the best way to prevent such a behaviour? As you can see in the picture there is a map under bottom bar. This bottom bar is like target/destination window in Google Maps app.
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<com.google.android.gms.maps.MapView
android:id="#+id/map"
tools:layout="#layout/fragmentMap"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical">
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp"/>
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical">
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:src="#drawable/draweR"/>
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_marginTop="40dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal">
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info"
/>
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info/>
</LinearLayout>
</LinearLayout>
</FrameLayout>
Use LinearLayout or RelativeLayout as top most parent instead of FrameLayout.
Here is the code snippet using LinearLayout.
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/textView1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center_vertical" />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button" />
</LinearLayout>
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
</ListView>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<ImageButton
android:id="#+id/draweR"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="left|center_vertical"
android:src="#drawable/draweR"/>
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
</FrameLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="75" />
<TextView
android:id="#+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="TextView"
android:layout_weight="25" />
</LinearLayout>
</LinearLayout>
You can mess around with the margins. I got it to look like the image you wanted.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.google.android.gms.maps.MapView
android:id="#+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:layout="#layout/fragmentMap" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:layout_marginTop="2dp"
android:orientation="vertical"
android:paddingBottom="160dp" >
<EditText
android:id="#+id/mapEditT"
android:layout_width="fill_parent"
android:layout_height="53dp"
android:layout_alignParentTop="true"
android:gravity="center|left"
android:paddingLeft="2dp"
android:paddingRight="0dp" />
<ListView
android:id="#+id/listVi"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:orientation="vertical" >
<ImageButton
android:id="#+id/draweR"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/draweR" />
<LinearLayout
android:id="#+id/infoBox"
android:layout_width="match_parent"
android:layout_height="100dp"
android:alpha="0.1"
android:background="#android:color/black"
android:orientation="horizontal" >
<TextView
android:id="#+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="20dp"
android:text="Info" />
<TextView
android:id="#+id/text3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_toRightOf="#id/text2"
android:text="Info" />
</LinearLayout>
</LinearLayout>
I want to place Image in the center and text just below it in a button, I tried to set android:gravity but could not set it properly,here is the image attached:
below is my xml:
<?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"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
android:background="#drawable/background_img"
>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_listen"
android:text="#string/listen"
android:drawableTop="#drawable/listen_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_gallery"
android:text="#string/gallery"
android:drawableTop="#drawable/gallery_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
<LinearLayout
android:layout_height="0dp"
android:layout_width="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:paddingLeft="10.0dip"
android:paddingTop="10.0dip"
android:paddingRight="10.0dip"
android:paddingBottom="10.0dip"
>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_play"
android:text="#string/play"
android:drawableTop="#drawable/play_btn"
android:layout_marginLeft="10dp"
android:layout_gravity="center"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
/>
<Button
android:layout_height="match_parent"
android:layout_width="0dp"
android:layout_weight="1"
android:id="#+id/button_find"
android:text="#string/find"
android:drawableTop="#drawable/test_btn"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_gravity="center"
/>
</LinearLayout>
</LinearLayout>
What is the proper way to center the image and text below it?
Many thanks in advance.
Try this its work for me
<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="match_parent"
tools:context=".MainActivity" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="151dp"
android:onClick="onClick"
android:drawableTop="#drawable/ic_launcher"
android:text="Button" />
</RelativeLayout>
Try change the button to LinearLayout and use same onclicklistener on fakebutton
<LinearLayout
android:id="#+id/fakeButton"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="center_vertical|center_horizontal"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon_big_evento" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/menu_about" />
</LinearLayout>
I followed DjHacktorReborn comments and made the layout, here is the freezed 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:background="#drawable/background_img"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical"
android:weightSum="10" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="2"
android:orientation="horizontal"
android:stretchColumns="*" >
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_listen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/listen"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_content_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/listen_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_gallery"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/gallery"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/main_icon_schedule_image_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/gallery_btn" />
</RelativeLayout>
</TableRow>
<TableRow android:layout_weight="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_play"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:ellipsize="marquee"
android:paddingTop="90dp"
android:text="#string/play"
android:textStyle="bold"
android:textColor="#FFFFFF"
/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/play_btn" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Button
android:id="#+id/button_find"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/main_list"
android:paddingTop="90dp"
android:text="#string/find"
android:textStyle="bold"
android:textColor="#FFFFFF" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:src="#drawable/test_btn" />
</RelativeLayout>
</TableRow>
</TableLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="4.1"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</LinearLayout>
Here is the updated result
Thanks for the suggestions