Three children on RelativeLayout does not get place to be shown - android

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>

Related

Expandable Gridview is not showing the full content

I am using Expandable GridView which doesn't scroll the whole content if grid items are changed dynamically.
Below is the xml code for main gridview
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="135dp">
<android.support.v4.view.ViewPager
android:id="#+id/pager1"
android:layout_width="match_parent"
android:layout_height="135dp"
android:layout_above="#+id/titles"
android:overScrollMode="never">
</android.support.v4.view.ViewPager>
<com.viewpagerindicator.CirclePageIndicator
android:id="#+id/titles"
style="#style/CustomCirclePageIndicator"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:padding="5dp" />
</RelativeLayout>
<fone.adipoli.shopping.ExpandableHeightGridView
android:id="#+id/gridView_shopping"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:horizontalSpacing="0dp"
android:listSelector="#android:color/transparent"
android:numColumns="2"
android:stretchMode="columnWidth"
android:verticalSpacing="0dp" />
</LinearLayout>
Xml for each Grid item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/white"
android:orientation="vertical">
<android.support.v7.widget.CardView
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:id="#+id/cardrow1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
card_view:cardCornerRadius="3dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center">
<ImageView
android:id="#+id/img_grid_row1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
/>
</LinearLayout>
<TextView
android:id="#+id/grid_row1_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text=""
/>
<TextView
android:id="#+id/grid_row1_model"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
android:visibility="gone" />
<TextView
android:id="#+id/grid_row1_price_offr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:id="#+id/grid_row1_price"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="10sp"
/>
<TextView
android:id="#+id/grid_row1_product"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text=""
android:textSize="10sp"
android:visibility="gone"
/>
<TextView
android:id="#+id/buy_grid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="2dp"
android:text="BUY"
android:padding="10dp"
android:gravity="center"
android:textColor="#color/white"
android:background="#color/blue"
android:textAppearance="? android:attr/textAppearanceSmall"/>
</LinearLayout>
</android.support.v7.widget.CardView>
I tried adding a view in the bottom after GridView ,but it doesn't work out.
Any help would be really thankfull.
Use android.support.v4.widget.NestedScrollView
or
ScrollView
Put your whole Grid items in NestedScrollView, or ScrollView seems to solve your problem.

Cannot click button within relativelayout that has linearlayout

Below is my xml file with problem.
When I remove the linear layout and let spinner in relative_layout it works
fine but as soon as I put them in Linear_layout, button and edit_box cannot be pressed. Please help.
<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" >
<AutoCompleteTextView
android:id="#+id/trainid"
android:hint="#string/train"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/button"
android:text="#string/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/traindetails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/trainid"
android:text="" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/traindetails"
android:orientation="horizontal" >
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/selectcurrentstation"
android:spinnerMode="dropdown"
android:layout_weight="0.5" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/selecttargetstation"
android:spinnerMode="dropdown"
android:layout_weight="0.5" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/selectcurrentstation" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1"
android:id="#+id/table" />
</ScrollView>
</RelativeLayout>
When I change my xml file to this it works fine. But I want the above layout.
<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" >
<AutoCompleteTextView
android:id="#+id/trainid"
android:hint="#string/train"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:focusable="true" />
<Button
android:id="#+id/button"
android:text="#string/search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:focusable="true" />
<TextView
android:id="#+id/traindetails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/trainid"
android:text="" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/selectcurrentstation"
android:spinnerMode="dropdown"
android:layout_below="#id/traindetails" />
<Spinner
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/selecttargetstation"
android:spinnerMode="dropdown"
android:layout_below="#id/selectcurrentstation" />
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/selectcurrentstation" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1"
android:id="#+id/table" />
</ScrollView>
</RelativeLayout>
MAke a little changes in the 1st code and your code will work fine.
In the linear layour (user as parent of two spinner) give it the id ex. linear_layout1.
The spinner layout(used as parent of table layout) change the layout_below id to the above ie linear_layout1.
<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"
>
<AutoCompleteTextView
android:id="#+id/trainid"
android:hint="Train"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true" />
<Button
android:id="#+id/button"
android:text="Search"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true" />
<TextView
android:id="#+id/traindetails"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/trainid"
android:text="" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/selectstation1"
android:layout_below="#id/traindetails"
android:orientation="horizontal" >
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/selectcurrentstation"
android:spinnerMode="dropdown"
android:layout_weight="0.5" />
<Spinner
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/selecttargetstation"
android:spinnerMode="dropdown"
android:layout_weight="0.5" />
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#id/selectstation1" >
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1"
android:id="#+id/table" />
</ScrollView>
</RelativeLayout>

ExpandableListView expanding over other layout

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>

ScrollView and Wrap_Content not work

I have a problem in my xml, the ScrollView does not work when my RelativeLayout is wrap_content, but if I have a larger screen than the fixed height works correctly, but if I have a larger fixed height than screen the works correctly, but I need to be wrap_content, because I have a listview that is populated gradually as client wants, follows the xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:background="#fff">
</LinearLayout>
<ScrollView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="45"
android:fillViewport="true"
android:scrollbars="vertical">
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:orientation="vertical">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="top|center_horizontal"
android:id="#+id/lb_cabec"
android:text="#string/str_cabec" />
<TextView
android:id="#+id/lb_pessoa_status"
android:paddingTop="4dp"
android:paddingBottom="15dp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:textStyle="bold"
android:text="#string/pessoas_lb_mesa_cartao"
android:layout_below="#+id/lb_cabec"/>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_prod"
android:layout_below="#+id/lb_pessoa_status">
<TextView
android:layout_width="fill_parent"
android:id="#+id/lb_prodMistAdd_cabec_prod"
android:layout_height="wrap_content"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_prod" />
<ListView
android:id="#+id/mListProdMistAdd_prod"
android:layout_width="fill_parent"
android:layout_marginBottom="10dp"
android:layout_height="wrap_content"
android:layout_below="#+id/lb_prodMistAdd_cabec_prod" />
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="#+id/mListProdMistAdd_prod"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_addProd"
android:text="#string/prodMistAdd_bt_prod" />
</RelativeLayout>
<LinearLayout
android:layout_height="10dp"
android:layout_width="fill_parent"
android:id="#+id/lb_espaco_1"
android:layout_below="#+id/relative_prod"
android:orientation="vertical">
</LinearLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_quant"
android:layout_below="#+id/lb_espaco_1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/lb_prodMistAdd_cabec_quant"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_quant" />
<LinearLayout
android:layout_height="5dp"
android:id="#+id/tab_espaco_2"
android:layout_below="#+id/lb_prodMistAdd_cabec_quant"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#fff">
</LinearLayout>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_centerHorizontal="true"
android:layout_below="#+id/tab_espaco_2"
android:orientation="horizontal">
<EditText
android:id="#+id/tb_prodMistAdd_quantidade"
android:layout_width="60dp"
android:layout_height="wrap_content"
android:editable="false"
android:gravity="center_vertical|right"
android:ems="10"
android:inputType="textPersonName" />
<Button
android:layout_width="40dp"
android:layout_height="35dp"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_mais"
android:text="#string/prodMistAdd_bt_mais" />
<Button
android:layout_width="40dp"
android:layout_height="35dp"
android:gravity="center_horizontal"
android:id="#+id/bt_prodMistAdd_menos"
android:text="#string/prodMistAdd_bt_menos" />
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_height="10dp"
android:layout_width="fill_parent"
android:id="#+id/lb_espaco_2"
android:orientation="vertical"
android:layout_below="#+id/relative_quant">
</LinearLayout>
<RelativeLayout
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:padding="2dp"
android:background="#drawable/borda"
android:id="#+id/relative_obs"
android:layout_below="#+id/lb_espaco_2">
<TextView
android:layout_width="fill_parent"
android:id="#+id/lb_prodMistAdd_cabec_obs"
android:layout_height="wrap_content"
android:background="#000"
android:textColor="#fff"
android:gravity="center_horizontal"
android:text="#string/prodMistAdd_str_obs" />
<LinearLayout
android:layout_height="5dp"
android:id="#+id/tab_espaco_3"
android:layout_below="#+id/lb_prodMistAdd_cabec_obs"
android:layout_width="fill_parent"
android:orientation="vertical"
android:background="#fff">
</LinearLayout>
<ListView
android:id="#+id/mListProdMistAdd_obs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="none"
android:layout_below="#+id/tab_espaco_3" />
<Button
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_below="#+id/mListProdMistAdd_obs"
android:layout_centerHorizontal="true"
android:gravity="center_horizontal"
android:id="#+id/bt_log_voltar"
android:text="#string/prodMistAdd_bt_obs" />
</RelativeLayout>
</RelativeLayout>
</ScrollView>
<LinearLayout
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1">
</LinearLayout>
</LinearLayout>
My listview are configured to not scroll, through code
try do define ScrollView layout_width and layout_height as match_parent, without layout_weight
by the way, you should not mix ScrollView with ListView since both have his own scroll. I suggest to split it like:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
(...)
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>

scrollview extending to whole layout

I have a layout as below
<LinearLayout>
<RelativeLayout>
</RelativeLayout>
<ScrollView>
<LinearLayout>
<LinearLayout>
</ScrollView>
</LinearLayout>
this is to divide the screen into half showing graph at one half of the screen and the report at the other half which alone i wish to be scrollable.
UPDATE
Please find the xml as below
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#888888" />
<LinearLayout
android:id=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10sp"
android:layout_marginBottom="10sp"
android:orientation="vertical">
<TextView
android:id=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textColor=""
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id=""
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:textColor=""
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="#888888"
android:orientation="vertical" />
<LinearLayout
android:id=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:visibility="visible"
android:orientation="horizontal">
<RelativeLayout
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:layout_weight="1"
android:layout_width="0dp"
android:layout_gravity="left"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
android:background="#FFFFFF"
android:orientation="vertical">
<TextView
android:id="#+id/course_status"
android:layout_alignParentLeft="true"
android:textColor="#000000"
android:textSize="14sp"
android:paddingLeft="10dp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="50dp"/>
<ImageView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src=""
android:id=""
android:layout_marginTop="50dp" />
<edu.apollogrp.android.widget.ProgressCircle
android:id=""
android:layout_width="170dp"
android:layout_height="170dp"
android:indeterminateOnly="false"
android:layout_centerInParent="true"
android:progressDrawable=""
android:layout_marginTop="50dp"
/>
<ImageView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src=""
android:id=""
android:layout_marginTop="50dp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignRight=""
android:layout_alignWithParentIfMissing="true"
android:layout_centerVertical="true"
android:addStatesFromChildren="false"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:orientation="horizontal" >
<TextView
android:id="#
android:textColor="#color/grades_green"
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"></TextView>
<TextView
android:id="#
android:textColor=""
android:textSize="20sp"
android:textStyle="bold"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"> </TextView>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
android:clipToPadding="false"
android:orientation="vertical"
android:layout_marginLeft="40dp" >
<TextView
android:id="#
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#color/grades_green"
android:textSize="12sp"
android:textStyle="bold" >
</TextView>
<TextView
android:id="#
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:textSize="9sp"
android:textStyle="bold" >
</TextView>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="1dp"
android:layout_height="fill_parent"
android:layout_marginLeft="5dp"
android:background="#888888"
android:orientation="horizontal" />
<ScrollView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:fillViewport="false"
>
<LinearLayout
android:id="#
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="wrap_content"
>
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
but the whole layout is scrollable now :(
Is there any way i can make only half the screen scrollable?
PS: android:fillViewport is set to false
UPDATE
I found out why the scroll is not working. it was because the scroll was inside a pull to refresh list view. :(
Looking for a work around for that now
Use layout_weight, here is sample code
<LinearLayout>
<RelativeLayout android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
</RelativeLayout>
<ScrollView android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<LinearLayout>
<LinearLayout>
</ScrollView>
</LinearLayout>
try to put the layout_weight attribute to divide the screen.
<LinearLayout>
<RelativeLayout android:layout_weight="1">
</RelativeLayout>
<ScrollView android:layout_weight="1">
<LinearLayout>
<LinearLayout>
</ScrollView>
</LinearLayout>
you can try this:
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF"
android:orientation="horizontal">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parentt"
android:layout_marginLeft="5dp"
android:background="#ffff"
android:layout_weight="1">
////// Your left side layout content /////////
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:background="#ffff"
android:orientation="vertical"
android:layout_weight="1">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:scrollbars="vertical"
android:layout_width="wrap_content"
android:orientation="horizontal"
android:layout_height="wrap_content"
>
<TextView
android:id=""
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp" />
</LinearLayout>
</ScrollView>
</LinearLayout>
</LinearLayout>
The scroll view was not working because it was inside a list view that implements the pull to refresh.. Hence the layout changes dont effect.
Sorry everyone, thanks a bunch for the help.

Categories

Resources