Android listview inside relative layout - android

Have somebody implemented ExpandableListView inside layout? I'm trying to do it and I have problems with height. I want to make it "wrap_content" in order to see fully expanded View when it is expanded. But unfortunately with "wrap_content" parameter I cannot achieve this result. Can somebody help?
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/user"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentTop="true"
android:layout_below="#+id/rl"
android:layout_toRightOf="#+id/user"
android:paddingLeft="3dp"
android:text="Top User"
android:textColor="#000000"
android:textSize="22dp" />
<ExpandableListView
android:id="#+id/elvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/user"
android:layout_above="#+id/about" >
</ExpandableListView>
<TextView
android:id="#+id/about"
android:layout_width="match_parent"
android:layout_height="100dp"
android:layout_alignParentBottom="true"
android:text="Bottom About"
android:textColor="#6f6f6f"
android:textSize="24dp"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
Group row in ExpandableListView:
<?xml version="1.0" encoding="utf-8"?>
<TextView android:id="#+id/groupname"
xmlns:android="http://schemas.android.com/apk/res/android"
android:textStyle="bold"
android:textSize="20dp"
android:paddingLeft="40dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:background="#drawable/expanded_upper_selector"
android:gravity="center_vertical"/>
Child Row:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/ingredients_selector">
<TextView android:id="#+id/ingredients_second_layer_text"
android:textStyle="bold"
android:textSize="20dp"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:textColor="#color/dark_orange"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"/>

Check out this link - http://about-android.blogspot.in/2010/04/steps-to-implement-expandablelistview.html
Here only one custom text is added.in similar way you can add second one.Try this and if any query you can feel free to ask.Hope this will help you.

Try your XML edited some-much:
Your_XYZ_Main_XML::
<?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" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#000000" >
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#00ff00" >
<TextView
android:id="#+id/user"
android:layout_width="match_parent"
android:layout_height="100dp"
android:paddingLeft="3dp"
android:text="Top User"
android:textColor="#111111"
android:background="#eeeeee"
android:textSize="22dp" />
<ExpandableListView
android:id="#+id/elvMain"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1" >
</ExpandableListView>
<TextView
android:id="#+id/about"
android:layout_width="match_parent"
android:layout_height="100dp"
android:text="Bottom About"
android:textColor="#6f6f6f"
android:textSize="24dp"
android:textStyle="bold" />
</LinearLayout>
</ScrollView>
</RelativeLayout>
Group_Row_XML ::
<?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:orientation="vertical" >
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/groupname"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#159357" // YOUR_BACKGROUND
android:gravity="center_vertical"
android:minHeight="?android:attr/listPreferredItemHeight"
android:paddingLeft="40dp"
android:text="Parent text"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="20dp"
android:textStyle="bold" />
</RelativeLayout>
Child_Row_XML ::
<?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:orientation="vertical" >
<TextView android:id="#+id/ingredients_second_layer_text"
android:textStyle="bold"
android:textSize="20dp"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:textColor="#ff2211" // YOUR_COLOR
android:text="Child Text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minHeight="?android:attr/listPreferredItemHeight"
android:textAppearance="?android:attr/textAppearanceLarge"
android:gravity="center_vertical"/>
</RelativeLayout>

Related

Center Controls in Android View..HowTo?

i have a Fragment with following Layout:
<?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="?android:attr/listPreferredItemHeight"
android:orientation="horizontal"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:background="#ffffff"
android:id="#+id/dateItemRow"
>
<TextView
android:id="#+id/timeField"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:textStyle="bold"
android:layout_marginTop="3dp"
android:paddingBottom="0dp"
android:textColor="#5d6265"
android:textSize="16sp" />
<LinearLayout
android:id="#+id/rowBackground"
android:layout_width="3dp"
android:layout_height="match_parent"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#33b5e6"
>
<TextView
android:id="#+id/seperator"
android:layout_width="2dp"
android:layout_height="fill_parent"
android:textColor="#000000"
android:text=""
/>
</LinearLayout>
<CheckBox
android:id="#+id/mycheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:button="#drawable/custom_checkbox_design"
/>
</LinearLayout>
How you (hopefully) see this is a Layout where on the Left site is a Time Field then kind a Border to separate the TimeField from the CheckBox. What i'm looking for is to set all of them to Center.
Actual everything is on the Left Site.
All this is in a ListView what i have described like this:
<?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="#e8e8e8" >
android:orientation="vertical" >
<ListView
android:id="#+id/listView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#e8e8e8" >
</ListView>
</LinearLayout>
I really have NO Idea how i can get this. THX for your HELP!!
Try adding
android:gravity="center"
to your outer LinearLayout.

Listview not scrolling totally android

I have a ListView that is not scrolling for complete. I inserted 20 items, but the listview is scrolling until the item 15º.
My Layout XML code here :
<?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:weightSum="1" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.6"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ListView
android:id="#+id/checklistview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</RelativeLayout>
</LinearLayout>
Here a screenshot:
I don't understand WHY this is happening. For example, If I put 6 items, the 6º item is not show and I can't scroll the listview. Missing something?
The problem is in your layout xml
change it with this one:
<?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" >
<RelativeLayout
android:id="#+id/topPart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<ListView
android:id="#+id/checklistview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/topPart" >
</ListView>
</RelativeLayout>
You should not add multiple enties below each other using android:layout_height="fill_parent" or "match_parent" (which is the same) in the same layout as you do in the LinearLayout.
Make it another RelativeLayout with using layout_below, layout_parentOnBottom and other options or place everything into one huge relative layout.
<?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:weightSum="1" >
<RelativeLayout
android:id="#+id/toppart"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/sky" >
<TextView
android:id="#+id/tvQuote"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginLeft="6dp"
android:layout_marginRight="6dp"
android:gravity="center_vertical|center_horizontal"
android:scrollbars="none"
android:text="#string/QuoteTeste"
android:textAlignment="center"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/white"
android:textSize="14pt" />
<Space
android:id="#+id/espaco"
android:layout_width="wrap_content"
android:layout_height="30dp" >
</Space>
<TextView
android:id="#+id/tvAutor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/tvQuote"
android:layout_below="#+id/tvQuote"
android:layout_marginTop="22dp"
android:text="(Carlos Drummond)"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/white" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/bottompart"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_below="#+id/toppart"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ListView
android:id="#+id/checklistview"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" >
</ListView>
</RelativeLayout>

Android: TextView not appearing below ListView

I checked out a similar question to this but it didn't solve my problem.
From top to bottom, I'm try to display:
a TextView (header)
a ListView with an index strip to the right of it (I use horizontal LinearLayout for this pair)
a TextView (footer)
Everything appears except my footer TextView.
Can somebody please tell me what is wrong with my XML?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/tvHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:background="#00F"
android:textColor="#android:color/white"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content" >
<ListView
android:id="#android:id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fastScrollEnabled="true" />
<LinearLayout
android:id="#+id/sideIndex"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:background="#FFF"
android:gravity="center_horizontal"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:background="#0F0"
android:textColor="#F00"
android:textStyle="bold" />
</LinearLayout>
Try this..
change android:layout_height="wrap_content" to android:layout_height="0dp" and add android:layout_weight = "1" for the middle LinearLayout
Change this..
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content" >
to
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_weight = "1"
android:layout_height="0dp" >
LinearLayout
1) http://developer.android.com/reference/android/widget/LinearLayout.html
2) http://developer.android.com/guide/topics/ui/layout/linear.html
RelativeLayout
1) http://developer.android.com/reference/android/widget/RelativeLayout.html
2) http://developer.android.com/guide/topics/ui/layout/relative.html
Better you try RelativeLayout. Check this
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/tvHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#00F"
android:text="TextView"
android:textColor="#android:color/white"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/tvFooter"
android:layout_below="#+id/tvHeader"
android:orientation="horizontal" >
<ListView
android:id="#android:id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fastScrollEnabled="true" />
<LinearLayout
android:id="#+id/sideIndex"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:background="#FFF"
android:gravity="center_horizontal"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
<TextView
android:id="#+id/tvFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#0F0"
android:text="TextView"
android:textColor="#F00"
android:textStyle="bold" />
</RelativeLayout>
add this attribute to your 2nd Linear layout.
android:layout_weight = "1"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent" >
<TextView
android:id="#+id/tvHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:background="#00F"
android:textColor="#android:color/white"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:layout_weight = "1" <!-- here -->
>
.......
You could use a RelativeLayout
<?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" >
<TextView
android:id="#+id/tvHeader"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="TextView"
android:background="#00F"
android:textColor="#android:color/white"
android:textStyle="bold" />
<TextView
android:id="#+id/tvFooter"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:background="#0F0"
android:text="TextView"
android:textColor="#F00"
android:textStyle="bold" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_below="#+id/tvHeader"
android:layout_above="#+id/tvFooter"
android:orientation="horizontal"
android:layout_height="wrap_content" >
<ListView
android:id="#android:id/list"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:fastScrollEnabled="true" />
<LinearLayout
android:id="#+id/sideIndex"
android:layout_width="40dip"
android:layout_height="wrap_content"
android:background="#FFF"
android:gravity="center_horizontal"
android:orientation="vertical" >
</LinearLayout>
</LinearLayout>
</RelativeLayout>
Use RelativeLayout, it will be easier to show or reposition other items.

Fill RelativeLayout parent with LinearLayout child

This seems simple but I've exhausted my Google search patience.
I have a RelativeLayout that has two sub LinearLayouts side-by-side and I want them both to vertically fill the parent, no matter the height of the two LinearLayouts. This is being used as a ListView row and the content under #id/item_left is generally shorter than the one on the right.
The background drawable doesn't fill the entire row.
Any ideas on making both sides fill?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/item_left"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingRight="2dp"
android:paddingLeft="2dp"
android:background="#drawable/item_left"
android:orientation="vertical">
<TextView android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/item_left_text"
android:text="" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/item_right_background"
android:layout_toRightOf="#id/item_left">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/item_right_text"
android:text="Row1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/item_right_text"
android:text="Row2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/item_right_text"
android:text="Row3" />
</LinearLayout>
</RelativeLayout>
try this code .... sorry but I changed the color to so the impact when you will change the text of first TextView
<?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="fill_parent"
android:background="#ffffffff" android:weightSum="1">
<LinearLayout android:id="#+id/item_left"
android:layout_width="wrap_content" android:layout_height="fill_parent"
android:paddingRight="2dp" android:paddingLeft="2dp"
android:background="#ff0000ff" android:orientation="vertical" >
<TextView android:id="#+id/time" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#ff555555"
android:text="sdfdsf s ada d a asd sad sad" />
</LinearLayout>
<LinearLayout android:layout_width="wrap_content"
android:layout_height="match_parent" android:orientation="vertical"
android:background="#ffff0000"
android:layout_weight="1" >
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#ff555555"
android:text="Row1" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#ff00ff00"
android:text="Row2" />
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:textColor="#ff00ff00"
android:text="Row3" />
</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="match_parent" >
<LinearLayout
android:id="#+id/layout1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#FF0000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="helloooooooooooooo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="#id/layout1"
android:background="#0000FF"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row2" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Row3" />
</LinearLayout>
</RelativeLayout>

No widget shows after scrollView in android

My design is like this: "Linearlayout start" "scrollview start" "scrollview end" "LinearLayout start" "LinearLayout end" "LinearLayout end". But second linear layout does not show in the screen.
code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<ScrollView
android:fillViewport="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date" />
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/nasa" />
<TextView
android:id="#+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/description" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button android:id="#+id/refresh" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/refresh">
</Button>
</LinearLayout>
</LinearLayout>
Thanks in advance
I found the solution. I need to add an extra attribute in ScrollView
<ScrollView android:layout_weight="1">
which prevent scroller to fill entire screen.
When your are using scrollView it needs to be as parent for the layout.
As per your code, follow the following code which was edited as per your requirement....
code:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:fillViewport="false"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title" />
<TextView
android:id="#+id/date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/date" />
<ImageView
android:id="#+id/imageView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/nasa" />
<TextView
android:id="#+id/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/description" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button android:id="#+id/refresh" android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/refresh">
</Button>
</LinearLayout>
</ScrollView>
Run the following code. It will execute...

Categories

Resources