I am making an android application that needs to use a scrollable layout that contains a couple of linearlayouts, a textview and a listview. How can i make this happen??? Please help and thanks SO much in advance! This is the xml code that i am using so far:
<?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="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NotesWelcomeText" />
<ListView
android:id="#+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView>
<LinearLayout
android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteAllButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
<EditText
android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/Add" />
</LinearLayout>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="#string/terms_and_conditions" />
</ScrollView>
Make your main layout as scroll layout inside that put the linear layout.
Keep in mind Scroll layout can hold only one type of item...
Once you do this, the whole layout is scroll able up and down or left and right as per your XML config.
Related
I am really getting frustrated with the layout as shown below:
I would like to have listview and below that I need to have two buttons side by side as shown above(LIstview should be scrollable and buttons should be as bottom bar ie..ontop tof the listview ). I have tried using android:layout_above and android:layout_below but nothing worked.Can anyone gimme an idea how to achieve this layout ?
This is what my layout code as of now actually I have this code where I am able to achieve this but I'm unable to click the buttons here.
<?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:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/secondLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/secondLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffffff"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/redbutton"
android:onClick=""
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#drawable/redbutton"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
Step #1: Get rid of the useless LinearLayout wrapping your ListView, moving the android:padding attribute into the ListView.
Step #2: Add android:layout_alignParentTop="true" and android:layout_above="#+id/firstLayout to the ListView.
Step #3: Get rid of android:layout_above="#id/secondLayout" from the remaining LinearLayout, as you definitely do not want that above the ListView.
Step #4: Switch from dp to sp for your Button dimensions, to take into account font scaling.
Step #5: Either change the width of the LinearLayout to wrap_content or remove the android:layout_centerHorizontal="true", as you cannot center something that fills all available space.
Off the cuff, the rest should be OK, or at least be a lot closer to what you want.
how about adding the buttons to your actionbar?
Otherwise wrap the ListView inside an ScrollView and make your RelativeLayout to LinearLayout
this is working. What problem are you facing exactly?
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:id="#+id/secondLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#id/secondLayout"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffff"
android:gravity="bottom"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:background="#FF0000"
android:onClick="test"
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:onClick="test"
android:background="#FF0000"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
This may work for you:
<?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:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<ListView
android:id="#+id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_above="#+id/firstLayout" />
<LinearLayout
android:id="#+id/firstLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:background="#00ffffff"
android:orientation="horizontal"
android:padding="15dp" >
<Button
android:id="#+id/btnPrevious"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:onClick=""
android:text="Previous"
android:textColor="#ffffff" />
<Button
android:id="#+id/btnNext"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:text="Next"
android:textColor="#ffffff" />
</LinearLayout>
</RelativeLayout>
I have a little problem defining a Relative Layout. I have a List View with scroll and two buttons always visible at the bottom of the list view. I just would like my two button have 50% of the width, filling the line. This is my code:
<?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"
android:orientation="vertical" >
<Button
android:id="#+id/testbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Save" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/testbutton"
android:text="Cancel"/>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_alignParentTop="true"
android:layout_above="#id/testbutton" />
</RelativeLayout>
I tried to introduce the buttons in a Linear Layout and give the gravity=1 with width=0dp but in that case the ListView dissapears. Could you help me please?
Sorry for my english. This is the result I would like to have:
Thanks a lot, best regards.
EDIT: This is what I tried with Linear 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"
android:orientation="vertical" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/container" >
<Button
android:id="#+id/testbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:text="Guardar" />
<Button
android:id="#+id/cancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/testbutton"
android:text="Cancelar"/>
</LinearLayout>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_alignParentTop="true"
android:layout_above="#id/container" />
</RelativeLayout>
Did you try with your LinearLayout in this way because this should work. Note all of the property changes. Since I don't know how yours was, I can't point out all of the differences.
<?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/btnLL"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Save" />
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Cancel"/>
</LinearLayout>
<ListView android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/LstPeriodOptions"
android:layout_above="#id/btnLL" />
</RelativeLayout>
Try out as below to set your button in LinearLayout and set it below your ListView:
<LinearLayout
android:id="#+id/laytbtns"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#+id/LstPeriodOptions" >
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
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:orientation="vertical" >
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/LstPeriodOptions"
android:layout_above="#id/testbutton" />
<LinearLayout
android:id="#+id/laytbtns"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="#+id/LstPeriodOptions" >
<Button
android:id="#+id/testbutton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:layout_weight="1"
android:text="Save"/>
<Button
android:id="#+id/cancelButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
I want to do something very simple. I want a layout that has a spinner at the top, followed by a List View, followed by a Linear Layout at the very bottom that wraps some buttons. I want the List View to expand to fill the space between the spinner and the buttons, no matter how big the window is. I have been trying this with a Linear Layout wrapping all three elements and I have tried every combination of Wrap Content and Fill Parent for Layout_Height that I can think of but unless I hard code the List View Layout_Height to say 300 dip, the buttons are pushed off the screen. I know that there must be an easy way to do this but I am at my wits end. I have tried everything I can think of.
Here is the code that works with the hard-coded height.
<?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" >
<Spinner
android:id="#+id/fileType"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<ListView
android:id="#+id/android:list"
android:layout_width="fill_parent"
android:layout_height="300dip" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="bottom"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/ManageFiles_DeleteItem"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Delete item" />
<Button
android:id="#+id/ManageFiles_DeleteAll"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Delete all" />
<Button
android:id="#+id/ManageFiles_DisplayItem"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Display item" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/ManageFiles_OKcustom"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="10dip"
android:layout_weight="1"
android:text="OK" />
<Button
android:id="#+id/ManageFiles_CancelCustom"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="10dip"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
`
You can try something as simple as
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<Spinner
android:id="#+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/spinner1"
android:layout_above="#+id/button1" >
</ListView>
<Button
android:id="#id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="Button1" />
<Button
android:id="#id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="Button2" />
The trick is to use RelativeLayout instead of LinearLayout.
Use the Following
android:weightSum="Your total length" //in your main layout
android:layout_weight="" //in each of your listview,spinner,linearlayout
Eg: if u need equal space for all 3 elements use
android:weightSum="3"
then in
Spinner
android:layout_weight="1"
/>
ListView
android:layout_weight="1"
/>
LinearLayout
android:layout_weight="1"
/>
Use weight, give weight of two to the list view and 1 each to the spinner and layout at bottom containing the buttons you can then vary the weight and check out which suits you more.
Try it like this way it will fit to all screen size.
<?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"
android:orientation="vertical" >
<LinearLayout
android:id="#+id/ftr_btn"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/ManageFiles_DeleteItem"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Delete item" />
<Button
android:id="#+id/ManageFiles_DeleteAll"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Delete all" />
<Button
android:id="#+id/ManageFiles_DisplayItem"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="5dip"
android:layout_weight="1"
android:text="Display item" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/ManageFiles_OKcustom"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="10dip"
android:layout_weight="1"
android:text="OK" />
<Button
android:id="#+id/ManageFiles_CancelCustom"
android:layout_width="fill_parent"
android:layout_height="40dip"
android:layout_margin="10dip"
android:layout_weight="1"
android:text="Cancel" />
</LinearLayout>
</LinearLayout>
<Spinner
android:id="#+id/fileType"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true" />
<ListView
android:id="#+id/listView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ftr_btn"
android:layout_alignParentLeft="true"
android:layout_below="#+id/fileType" >
</ListView>
I am making an android application that uses these views:
(Root) - LinearLayout
(Child of root) - ListView + 3 other linearlayouts beneeth that listview. But once i add to many items to the listview, the layouts are being placed outside of the screen. Which i don't want to. How can i make this happen? So that all of the three linearlayouts stay on the screen, at the bottom??? Please help and thanks in advance!
My screen XML 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:background="#drawable/background"
android:orientation="vertical" >
<TextView
android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/NotesWelcomeText" />
<ListView
android:id="#+android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</ListView
<LinearLayout
android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteAllButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:visibility="invisible" >
<Button
android:id="#+id/CancelButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Cancel" />
<Button
android:id="#+id/DeleteButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/Delete" />
</LinearLayout>
<LinearLayout
android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:visibility="gone" >
<EditText
android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_weight="1" >
</EditText>
<Button
android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/Add" />
</LinearLayout>
</LinearLayout>
Try this, you'll have to add the string references and background again, I removed them so I wouldn't have errors
<?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"
android:orientation="vertical">
<TextView android:id="#+id/NotesWelcomeTextView"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="NotesWelcomeText" />
<ListView android:id="#+android:id/list" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_above="#+id/AddItemToListViewLinearLayout"
android:layout_below="#+id/NotesWelcomeTextView">
</ListView>
<LinearLayout android:id="#+id/DeleteAllItemsFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton2" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteAllButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/DeleteItemFromListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:layout_weight="1" android:visibility="invisible"
android:layout_alignParentBottom="true">
<Button android:id="#+id/CancelButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Cancel" />
<Button android:id="#+id/DeleteButton" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Delete" />
</LinearLayout>
<LinearLayout android:id="#+id/AddItemToListViewLinearLayout"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:visibility="gone" android:layout_alignParentBottom="true">
<EditText android:id="#+id/AddItemToListViewEditText"
android:layout_width="250dp" android:layout_height="wrap_content"
android:layout_weight="1">
</EditText>
<Button android:id="#+id/AddItemToListViewButton"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_weight="1" android:text="Add" />
</LinearLayout>
Give your ListView a weight of 0 and set its height to 0. This will tell the ListView to only take up the space that is not use by other views.
<ListView ...
android:layout_weight="0"
android:layout_height="0"
...
/>
<?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" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EN LEZİZ KISIR TARİFİ BURADA"
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/kisir" />
<Button
android:id="#+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/malzemeler" />
<Button
android:id="#+id/button2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/hazirlanisi" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fillViewport="true" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="false"
android:text="#string/secenek" />
</ScrollView>
</LinearLayout>
When i click the button i want to be able to use the scrollView to be able to read the rest of the text and i kept text long in string values but i couldn't create scrollView. Where am i doing wrong? Thx.
You cannot use the scrollview inside the textview. You can use the scrollview instead of Linear layout. You are using scrollview in the wrong place.
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
android:singleLine="false"
android:text="Your Text" />
</LinearLayout>
</ScrollView>