1. Check out our companion app, Forums for Android! Download from Google Play

TableLayout issue using images

Discussion in 'Application Development' started by rick99gtp, Aug 17, 2010.

  1. rick99gtp

    rick99gtp Member
    Thread Starter
    15

    Aug 6, 2010
    12
    0
    15
    Hello,

    So, I'm trying to learn how to create different layouts and truly understand how to use them. What I'm trying to accomplish is a simple header image at the top of the screen, followed by 2 views (an imageview and a textview), equally spaced below that.

    So, I figured I'd put an ImageView for the header image. Below that, I created a TableLayout with one row, with an ImageView in the 1st column and a TextView in the 2nd column.

    I have a couple of questions:

    1. Is this the best way to do this?
    2. How do I know how big to make the images (in Photoshop or other graphics program)

    Here is my xml code. Any help would be greatly appreciated, as always! :)

    Code (Text):
    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3.     android:orientation="vertical"
    4.     android:layout_width="fill_parent"
    5.     android:layout_height="fill_parent">
    6.  
    7.  
    8.         <ImageView
    9.             android:src="@drawable/logoheader"
    10.             android:id="@+id/logoheader"
    11.             android:layout_width="fill_parent"
    12.             android:layout_height="wrap_content" />
    13.            
    14.         <TableLayout
    15.                 android:layout_width="fill_parent"
    16.                 android:layout_height="wrap_content">
    17.                 android:stretchcolumns="0, 1"
    18.  
    19.                 <TableRow>
    20.  
    21.                         <ImageView
    22.                                 android:id="@+id/nochances"
    23.                                 android:src="@drawable/nochances"
    24.                                 android:layout_height="wrap_content"
    25.                                 android:layout_width="wrap_content" />
    26.  
    27.                         <TextView
    28.                                 android:id="@+id/score"
    29.                                 android:layout_height="wrap_content"
    30.                                 android:layout_width="wrap_content"
    31.                                 android:text="Score:" />
    32.  
    33.                 </TableRow>
    34.  
    35.         </TableLayout>
    36.  
    37. </LinearLayout>
     

    Advertisement

  2. blundell

    blundell Well-Known Member
    38

    Apr 23, 2010
    125
    17
    38
    Software Engineer
    UK
    rick99gtp likes this.
  3. rick99gtp

    rick99gtp Member
    Thread Starter
    15

    Aug 6, 2010
    12
    0
    15
    Thanks.

    Maybe I'm making the image too small then. I'm just looking to place an image on the left and a "Score: #####" on the right....

    I'll mess with it some more.
     

Share This Page

Loading...