[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Android layout question

Posted on 2012-09-06
4
Medium Priority
?
661 Views
Last Modified: 2012-09-07
Hi

I have the following layout:

<LinearLayout>
<TextView>
<TextView>
<ScrollView>
<ListView>
</ScrollView>
<Button>
</LinearLayout>

When I put the ListView into the ScrollView I can only see one item of the ListView.
I am not sure what layout parameters I should be using
0
Comment
Question by:zattz
  • 2
4 Comments
 
LVL 13

Expert Comment

by:Molnar István
ID: 38372338
first add the button on the bottom of the relativelayout and then add the listview:

<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="fill_parent" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:text="Button" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/button1"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true" >

    </ListView>

</RelativeLayout>

http://www.experts-exchange.com/Programming/Languages/Java/Android/Q_27841691.html#a38339211
0
 

Author Comment

by:zattz
ID: 38373270
When I do it that way it puts the Button to the left of the ListView. I want the button at the top of the ListView, taking up the entire width of the linearlayout.
0
 
LVL 8

Accepted Solution

by:
Santhana earned 2000 total points
ID: 38375204
Hi zattz,

I thing this will help 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="fill_parent" >

    <TextView
        android:id="@+id/editText1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dip"
        android:text="Text1" />

    <TextView
        android:id="@+id/editText2"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@+id/editText1"
        android:layout_margin="10dip"
        android:text="Text2"
        android:textAlignment="gravity" />

    <ListView
        android:id="@+id/listView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_above="@id/button1"
        android:layout_below="@+id/editText2" />

    <Button
        android:id="@+id/button1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:text="Button" />

</RelativeLayout>
0
 

Author Closing Comment

by:zattz
ID: 38375670
Thank you, that was very helpful
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
Learn how to use the free Acronis True Image app to easily transfer data between iPhones and Android phones.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question