Layout: TextView at the top and ListView at the center

Benz

Currently my ListView is exactly below my TextView. How can I make the ListView at the center of the screen while my TextView maintain its position on top?

Below is my layout:

<?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/root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/hp_color"
tools:context=".MainActivity" >

<TextView
    android:id="@+id/cityText"
    style="?android:attr/textAppearanceMedium"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true" />

<TextView
    android:id="@+id/condDescr"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/cityText" />

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_below="@+id/condDescr"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/mainListView"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true" />
</LinearLayout>

</RelativeLayout>
NSouth

Try setting

android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"

And although I'm no expert here, it's my impression that there's little point to having a ListView in a LinearLayout. Both are scrollable (which isn't advised) and there's not much point if LinearLayout only has one child.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Center align TextView in android layout

From Dev

How to align textview in layout center using customlayout?

From Dev

Center TextView directly below ImageView in Linear Layout

From Dev

How to put a TEXTVIEW center on a IMAGEVIEW in Android Layout

From Dev

Align shape to center of textview on Relative layout

From Dev

Listview starts from center instead of top left

From Dev

TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

From Dev

How can I position the end edge of a TextView to the center of the layout?

From Dev

TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

From Dev

Cannot Center TextView Vertically using android:gravity="center_vertical" and android:layout_centerVertical="true"

From Dev

Layout: 1 TextView top, 2 ListViews middle (50/50), 1 EditText bottom

From Dev

Center UIView on screen using Auto Layout programmatically when the view is located at the top of the view hierarchy

From Dev

HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

From Dev

Scroll view of center aligned linear layout is wrapping top content in small resolution devices and landscape mode

From Dev

HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

From Dev

Creating own Listview Layout - "LinearLayout cannot be cast to android.widget.TextView"

From Dev

Android textview center positioning

From Dev

Center a button and textView

From Dev

Android textview center letter

From Dev

TextView will not center its content

From Dev

Android - Center Textview in LinearLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

Align TextView to center of RelativeLayout

From Dev

Center a TextView in a TableRow in a TableLayout

From Dev

TextView will not center its content

From Dev

Unable to center the text in textview

From Dev

Dynamically create textview in center

From Dev

TextView Center Gravity not working

From Dev

Show TextView always on top

Related Related

  1. 1

    Center align TextView in android layout

  2. 2

    How to align textview in layout center using customlayout?

  3. 3

    Center TextView directly below ImageView in Linear Layout

  4. 4

    How to put a TEXTVIEW center on a IMAGEVIEW in Android Layout

  5. 5

    Align shape to center of textview on Relative layout

  6. 6

    Listview starts from center instead of top left

  7. 7

    TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

  8. 8

    How can I position the end edge of a TextView to the center of the layout?

  9. 9

    TextView Alignment in LinearLayout android. Unable to place it at Center of Layout

  10. 10

    Cannot Center TextView Vertically using android:gravity="center_vertical" and android:layout_centerVertical="true"

  11. 11

    Layout: 1 TextView top, 2 ListViews middle (50/50), 1 EditText bottom

  12. 12

    Center UIView on screen using Auto Layout programmatically when the view is located at the top of the view hierarchy

  13. 13

    HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

  14. 14

    Scroll view of center aligned linear layout is wrapping top content in small resolution devices and landscape mode

  15. 15

    HTML CSS DIV Layout with Top, Left, and Right DIVs fixed with a scrolling Center DIV

  16. 16

    Creating own Listview Layout - "LinearLayout cannot be cast to android.widget.TextView"

  17. 17

    Android textview center positioning

  18. 18

    Center a button and textView

  19. 19

    Android textview center letter

  20. 20

    TextView will not center its content

  21. 21

    Android - Center Textview in LinearLayout

  22. 22

    Center a TextView in a TableRow in a TableLayout

  23. 23

    Align TextView to center of RelativeLayout

  24. 24

    Center a TextView in a TableRow in a TableLayout

  25. 25

    TextView will not center its content

  26. 26

    Unable to center the text in textview

  27. 27

    Dynamically create textview in center

  28. 28

    TextView Center Gravity not working

  29. 29

    Show TextView always on top

HotTag

Archive