ExpandableListView expanding over other layout - android

I have this layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/details" android:layout_width="match_parent"
android:layout_height="wrap_content" android:orientation="vertical"
android:gravity="center"
android:weightSum="1"
android:visibility="visible">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="Header text"
android:id="#+id/textView6"
android:background="#color/background"
android:textColor="#color/textColor"
android:padding="8dp" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:background="#color/headerBackground"
android:padding="8dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/textView7"
android:textStyle="bold" />
</LinearLayout>
<ExpandableListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/listview_items"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center|bottom">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Back"
android:id="#+id/buttonBack"
android:layout_weight="1"
android:clickable="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Next"
android:id="#+id/buttonNext"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
</RelativeLayout>
When the expandable listview has a long list of items, it expands over the bottom layout (the buttons layout).
Is there a way to tell the listview to expand up to where the bottom layout starts?

I have made some changes in your XML File.What I did is make your Button Layout android:layout_alignParentBottom="true" and make your details layout as android:layout_above="#+id/button_layout".Hope it will solve your issue.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:id="#+id/details"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/button_layout"
android:gravity="center"
android:orientation="vertical"
android:visibility="visible"
android:weightSum="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:orientation="vertical">
<TextView
android:id="#+id/textView6"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#color/background"
android:padding="8dp"
android:text="Header text"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/textColor"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="8dp"
android:background="#color/headerBackground"
android:orientation="vertical"
android:padding="8dp">
<TextView
android:id="#+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"/>
</LinearLayout>
<ExpandableListView
android:id="#+id/listview_items"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#null"
android:dividerHeight="0dp"
android:groupIndicator="#null"/>
</LinearLayout>
<LinearLayout
android:id="#+id/button_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_weight="1"
android:gravity="center|bottom"
android:orientation="horizontal">
<Button
android:id="#+id/buttonBack"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Back"/>
<Button
android:id="#+id/buttonNext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true"
android:text="Next"/>
</LinearLayout>
</RelativeLayout>

Related

Unable to align text to right of imageview android layout xml

I am trying to create layout like below in android:
But my problem is I am unable to add textbelow the image or on the right hand side of imageview. If I wrap ImageView and textview in a LinearLayout the then the whole view shrinks. Should I be using TableLayout?
My current layout xml is like below:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_below="#id/my_recycler_view"
android:layout_margin="30dp">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/comm_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 1"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room2"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/visitor_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room2"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 2"
/>
</RelativeLayout>
</LinearLayout>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="300dp"
android:orientation="vertical"
android:layout_weight="1"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/vwImageAndClassroom3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
>
<ImageView
android:id="#+id/img_room3"
android:layout_width="fill_parent"
android:layout_height="100dp"
android:layout_gravity="center_horizontal"
android:contentDescription="#string/coverimage_contentdescription"
android:scaleType="fitCenter"
android:src="#drawable/visitor_book_icon"
/>
<TextView
android:id="#+id/tv_emp_name3"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal|center_vertical"
android:textSize="12dp"
android:textStyle="bold"
android:textAllCaps="true"
android:layout_below="#id/img_room3"
android:layout_marginBottom="20dp"
android:gravity="center_horizontal"
android:text="TEXT 3"
/>
</RelativeLayout>
</LinearLayout>
</LinearLayout>
Hope this will help you and you will find your solutions from this xml code. I just modify some of your code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:id="#+id/image1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center"
android:src="#android:drawable/ic_search_category_default"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This Right side text 1"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is under layout text"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="This is under layout text"/>
</LinearLayout>
</LinearLayout>
Have placeholder views where text is not required.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="100dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<View
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:background="#color/next_green" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="text"/>
</LinearLayout>
</LinearLayout>
I did exactly what you want
Open image
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView3"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<ImageView
android:id="#+id/imageView2"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/textView5"
android:layout_width="match_parent"
android:layout_height="15dp"
android:text="Some text" />
<TextView
android:id="#+id/textView6"
android:layout_width="match_parent"
android:layout_height="15dp"
android:text="Some text" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView7"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView8"
android:layout_width="300dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="center"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="#+id/textView9"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Some text"
app:srcCompat="#android:drawable/btn_dialog" />
</LinearLayout>
</LinearLayout>
</LinearLayout>

how i can set my items to full screen of all device

how i can set my items to full screen of all device,
i have RecyclerView and CardView for horizontal and vertical listview
singleitems.xml :
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
app:cardCornerRadius="5dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_az"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_be"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripCondition"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="right"
android:gravity="right"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp">
<TextView
android:id="#+id/txt_tripDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
main_items.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="wrap_content"
android:background="?android:selectableItemBackground"
android:orientation="vertical"
android:padding="5dp">
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view_list"
android:layout_width="match_parent"
android:layout_height="300dp"
android:layout_gravity="center_vertical"
android:gravity="right"
android:orientation="horizontal" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="2dp"
android:background="#android:color/holo_green_dark">
<TextView
android:id="#+id/itemTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical"
android:layout_toLeftOf="#+id/btnMore"
android:text="Sample title"
android:textColor="#android:color/white"
android:textSize="18sp" />
<Button
android:id="#+id/btnMore"
android:layout_width="wrap_content"
android:layout_height="42dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="More" />
</RelativeLayout>
and i use like this in my activity_main.xml :
<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.software.mahoo.operator.Activityes.Act_Request">
<android.support.v7.widget.RecyclerView
android:id="#+id/my_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scrollbars="none"
android:gravity="right"/>
with this code my item is like this picture :
i want fit to all device fullscreen like this picture :
items is horizontal , and with swipe to right item change scroll to next item .
how i can do this ?

Linear layout below the ListView, Some portions not visible?

I have a problem with LinearLayout which is below the listview. I tried to give the listview weight and layout above, set the layout_height to 0dp but nothing wotked.
Here is my XML code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
when ListView fills the screen, I cannot see the buttons below to it.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="100">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30" />
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Your layout edited by adding layout weights. Please check.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.1"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.6">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:layout_weight="0.3"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
You should try List View with Layout having weight.
Sample Code:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
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="0.3"
/>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.4"
>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.3"
/>
</LinearLayout>
In this your height is fixed for listview. Assuming that you can use list view as srollable in particular height.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/topLayout"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:alignParentTop="true"
android:weightSum="100"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/bottomLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:alignParentBottom="true"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout">
</ListView>
</RelativeLayout>
Have edited your code. Try this.
Here in this I have used RelativeLayout, so that we use android:alignParentBottom="true" for bottom layout which makes the layout in fix in bottom. Simillarly we can do for top layout using android:alignParentBottom="true". Now coming to ListView, which we need to place between top and bottom layout I have used the following code to achieve it
android:layout_below="#+id/topLayout"
android:layout_above="#+id/bottomLayout"
This makes the ListView to stick in between the top and bottom layout.
Hope this is helpful:)
Change as below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#00c4ff">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Application № - "
android:layout_weight="50"/>
<TextView
android:id="#+id/number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="__"
android:layout_weight="20" />
<EditText
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="date"
android:hint="dd/mm/yyyy"
android:layout_weight="30"
/>
</LinearLayout>
<ListView
android:id="#+id/lvMain"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
</ListView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="bottom"
android:id="#+id/ll">
<Button
android:id="#+id/plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Add"/>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:id="#+id/comment"
android:inputType="text"
android:hint="Comment" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="bottom">
<Button
android:id="#+id/send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send" />
<Button
android:id="#+id/close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Save and close"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>

Android map with custom layout

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>

Three children on RelativeLayout does not get place to be shown

I am trying to show four direct children on a Relative Layout where first one is a EdiText (in 'gone' visibility) and second one is LinearLayout with a TextView and ImageView and third is a ListView and fourth is another LinearLayout.
ListView gets over all children. I am posting below the code.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollview"
android:background="#drawable/bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.antoinecampbell.gcmdemo.GcmActivity$PlaceholderFragment">
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<LinearLayout
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_below="#+id/recepient" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
</LinearLayout>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="gone"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</RelativeLayout>
Now I tried using LinearLayout with scrollview inside it, it's now not scrolling the listview
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<EditText
android:id="#+id/recepient"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:imeOptions="actionSend"
android:inputType="phone"
android:visibility="invisible">
<requestFocus />
</EditText>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:text="Preview"
android:textStyle="bold"
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone"/>
<ImageView android:id="#+id/imageShow"
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/abs__ic_go"
android:layout_gravity="center_horizontal"
android:visibility="gone"/>
<ListView android:id="#+id/listMessages"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/LinearLayout1"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:listSelector="#00000000"
/>
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/bottomview"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:layout_below="#+id/listMessages"
android:layout_alignParentBottom="true"
android:visibility="visible"
android:background="#FFFFFF">
<com.rockerhieu.emojicon.EmojiconEditText
android:id="#+id/name_edittext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/padding_small"
android:layout_weight="1"
android:hint="#string/enter_message_text"
android:imeOptions="actionSend"
android:inputType="text"
android:layout_gravity="center_vertical"
android:visibility="visible"/>
<LinearLayout android:layout_width="wrap_content"
android:id="#+id/frameView"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone">
<fragment
android:id="#+id/emojicons"
android:layout_width="match_parent"
android:layout_height="220dp"
class="com.rockerhieu.emojicon.EmojiconsFragment"/>
</LinearLayout>
<ImageButton
android:id="#+id/send_message_button"
android:background="#drawable/angry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:onClick="onClick"
android:visibility="visible"/>
</LinearLayout>
</LinearLayout>
The ListView will go over other elements because you've not given it any relative positions. In a relative layout, every element will be default appear at (0,0) (ie the top left corner of the view) unless it's given a layout_below, layout_alignBottom etc parameter to determine where it's drawn.
So in this case, you 'resumably want the ListView to have android:layout_below="#id/LinearLayout1 and the bottomview similarly android:layout_below="#id/listMessages.
Here is the xml as per your requirement.
<?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="match_parent"
android:layout_gravity="center"
android:gravity="center" >
<EditText
android:id="#+id/edNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:hint="Number"
android:inputType="phone"
android:visibility="gone" />
<LinearLayout
android:id="#+id/llLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/edNumber"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="linear layout text" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#drawable/ic_launcher" />
</LinearLayout>
<ListView
android:id="#+id/lvList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/llBottom"
android:layout_below="#id/llLayout" >
</ListView>
<LinearLayout
android:id="#+id/llBottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#ababab"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Bottom Bar text" />
</LinearLayout>
</RelativeLayout>

Categories

Resources