[android-developers] Re: layout problem

2012-12-24 Thread dashman
thanks - just what i was looking for.


On Monday, December 24, 2012 2:27:48 AM UTC-5, Sourav Howlader wrote:

 Just mention android:gravity=center to your Root LinearLayout


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: layout problem

2012-12-23 Thread Piren
change the linearlayout to warp_content and put it in a 
RelativeLayout/Framelayout and use the proper centering field 
(centerInParent/layout_gravity)

On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:

 I've got 3 View elements that i'd like to display at the center
 of the page - centered vertically and horizontally.

 for the life of me - i can't get it to work.

 i've tried layout_gravity set to center_vertical - but it does only one 
 element.

 maybe i need to group the 3 elements under another layout and then
 do a center_vertical on that???

 ?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 

 ImageView
 android:id=@+id/imageView1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:src=@drawable/hint /

 TextView
 android:id=@+id/editText1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text= 
 /TextView

 Button
 android:id=@+id/button1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_gravity=center_vertical|center_horizontal
 android:text=Got it! /
  
 /LinearLayout



On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:

 I've got 3 View elements that i'd like to display at the center
 of the page - centered vertically and horizontally.

 for the life of me - i can't get it to work.

 i've tried layout_gravity set to center_vertical - but it does only one 
 element.

 maybe i need to group the 3 elements under another layout and then
 do a center_vertical on that???

 ?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 

 ImageView
 android:id=@+id/imageView1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:src=@drawable/hint /

 TextView
 android:id=@+id/editText1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text= 
 /TextView

 Button
 android:id=@+id/button1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_gravity=center_vertical|center_horizontal
 android:text=Got it! /
  
 /LinearLayout



On Sunday, December 23, 2012 3:34:16 AM UTC+2, dashman wrote:

 I've got 3 View elements that i'd like to display at the center
 of the page - centered vertically and horizontally.

 for the life of me - i can't get it to work.

 i've tried layout_gravity set to center_vertical - but it does only one 
 element.

 maybe i need to group the 3 elements under another layout and then
 do a center_vertical on that???

 ?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 

 ImageView
 android:id=@+id/imageView1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:src=@drawable/hint /

 TextView
 android:id=@+id/editText1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text= 
 /TextView

 Button
 android:id=@+id/button1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_gravity=center_vertical|center_horizontal
 android:text=Got it! /
  
 /LinearLayout




-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: layout problem

2012-12-23 Thread Sourav Howlader
Just mention android:gravity=center to your Root LinearLayout


On Sunday, 23 December 2012 07:04:16 UTC+5:30, dashman wrote:

 I've got 3 View elements that i'd like to display at the center
 of the page - centered vertically and horizontally.

 for the life of me - i can't get it to work.

 i've tried layout_gravity set to center_vertical - but it does only one 
 element.

 maybe i need to group the 3 elements under another layout and then
 do a center_vertical on that???

 ?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 

 ImageView
 android:id=@+id/imageView1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:src=@drawable/hint /

 TextView
 android:id=@+id/editText1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:text= 
 /TextView

 Button
 android:id=@+id/button1
 android:layout_width=wrap_content
 android:layout_height=wrap_content
 android:layout_gravity=center_vertical|center_horizontal
 android:text=Got it! /
  
 /LinearLayout




-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: layout problem

2012-12-23 Thread Sourav Howlader
Just mention android:gravity=center to your Root LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: layout problem

2011-10-19 Thread viktor
http://developer.android.com/reference/android/widget/ImageView.html#attr_android:scaleType

set scale type to the fitXY

Or you can calculate width and height for your ImageView manualy by
ParentView (width, height) with correct aspect ration for your image.

On 19 Жов, 13:15, vani reddy vani.reddy.bl...@gmail.com wrote:
 Hi friends,

 In the attached snapshot i have 3 buttons which are vertically aligned,and
 an imageview to the left of it.
 I want the imageview to fill the width and have 3 buttons at the right
 side.How to accomplish that?

 I have used the below code

 ?xml version=1.0 encoding=utf-8?
 RelativeLayout xmlns:android=http://schemas.android.com/apk/res/android;
 android:background=#fff
     android:layout_width=fill_parent android:layout_height=fill_parent
     LinearLayout
     android:layout_width=fill_parent
     android:orientation=horizontal
     android:layout_height=wrap_content 

     ImageView android:id=@+id/thumbImage
 android:layout_width=wrap_content
     android:src=@drawable/index1
     android:layout_gravity=fill_horizontal
         android:layout_height=wrap_content /

         RelativeLayout
         android:orientation=vertical
         android:layout_alignParentRight=true
         android:layout_toRightOf=@id/thumbImage
         android:paddingRight=10dip
         android:id=@+id/main

         android:layout_centerHorizontal=true
         android:layout_centerVertical=true
         android:layout_width=wrap_content
         android:layout_height=wrap_content 

         ImageView android:id=@+id/check
 android:layout_width=wrap_content
         android:src=@drawable/check
         android:layout_gravity=center_horizontal|center
         android:layout_height=wrap_content
 android:layout_alignParentRight=true
          /
     ImageView android:id=@+id/bookmark
 android:layout_width=wrap_content
     android:layout_marginTop=5dip
     android:layout_below=@id/check
     android:src=@drawable/bookmark
     android:layout_gravity=center_horizontal|center
         android:layout_height=wrap_content
 android:layout_alignParentRight=true
          /
         ImageView android:id=@+id/delete
 android:layout_width=wrap_content
         android:src=@drawable/close
         android:layout_below=@id/bookmark
         android:layout_gravity=center_horizontal|center
         android:layout_marginTop=5dip
         android:layout_height=wrap_content
 android:layout_alignParentRight=true
          /
         /RelativeLayout

     /LinearLayout

 /RelativeLayout

 --
 Regards,
 Vani Reddy

  device.png
 44KДивитисьЗавантажити

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout problem with TextView on RelativeLayout

2011-07-22 Thread Abhishek Akhani
I have also encountered this problem i think 9 patch images take some 
space on all four sides which makes the inner content to squeeze you 
have to readjust your text view or just use png... :-)   this is what i 
did

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: layout problem

2010-10-18 Thread dashman

thanks - that was the problem.

but this seems like a layout bug.

if i have a LinearLayout with 3 elements in them
with the 1st and 3rd with layout_width of wrap_content and then
middle one with fill_parent. it seems relatively clear what i
want done. the middle element will take all the space after
the 1st and 3rd widths have been allocated.

even if i do a wrap_content, it doesn't work - tablelayout takes
the full rest of the row.

the only way it works - is with a hard pixel amount.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: layout problem

2010-10-18 Thread dashman

on further researh, it was the stretchColumns inside the
tablelayout - causing the problem

TableLayout
android:layout_width=fill_parent
android:layout_height=wrap_content
android:stretchColumns=1

but again, that attribute should be subservient to the layout_width.

if i set the width to wrap_content - it still strectches even though
the content width is quite a bit less than the remaining width.

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: layout problem

2010-10-17 Thread grace
hi,
your table layout as defined in your xml specifes to fill the parent
with its content.
that is why it is not showing up the second image button.
try to adjust the width of the table layout so that image button can
also be seen
TableLayout
 android:layout_width=fill_parent /here
 android:layout_height=wrap_content
 android:stretchColumns=1


On Oct 18, 7:49 am, dashman erjdri...@gmail.com wrote:
 i've got a linear layout - horz.

 with an image-view on the left and
 a tablelayout to it's right.

 works fine!

 i wanted to add an image-button to the
 right of the tablelayout.

 problem is that image-button never appears
 on the screen.

 if i comment out the tablelayout (i.e.
 just 2 image-views in the layout) - then
 the image-button shows up.

 i've verified the code for the image-button -
 it's correct.

 it's almost as if one cannot have a view
 after  a tablelayout - i.e. it takes up the
 remainder of the width.

 ?xml version=1.0 encoding=utf-8?

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
         android:orientation=horizontal
         android:layout_width=fill_parent
         android:layout_height=wrap_content
         android:paddingTop=5dip
         android:paddingBottom=5dip
                 android:background=#33

         ImageView android:id=@+id/main_child_image
                         android:paddingLeft=40dip
                         android:paddingRight=5dip
                         android:layout_gravity=center_vertical
                                 android:layout_width=wrap_content
                 android:layout_height=wrap_content /

 TableLayout
     android:layout_width=fill_parent
     android:layout_height=wrap_content
     android:stretchColumns=1

     TableRow

         TextView
             android:id=@+id/main_child_text1
                         style=@style/style_main_child_text1 /

         TextView
             android:id=@+id/main_child_text2
                         style=@style/style_main_child_text2 /

         TextView
             android:id=@+id/main_child_text6
                         style=@style/style_main_child_text6 /

     /TableRow

     TableRow
         TextView
             android:id=@+id/main_child_text3
                         style=@style/style_main_child_text3 /
         TextView
             android:id=@+id/main_child_text4
                         style=@style/style_main_child_text4 /
         TextView
             android:id=@+id/main_child_text5
                         style=@style/style_main_child_text5 /
     /TableRow

 /TableLayout

         ImageButton android:id=@+id/status_button           !--
 this is not showing up --
                         android:src=@drawable/status_button    !-- if i 
 comment
 the tablelayout - then it shows--
                         android:layout_gravity=center_vertical
                                 android:layout_width=32px
                 android:layout_height=32px /

 /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout Problem in different screen size

2010-08-20 Thread optimusgeek
LinearLayout
android:orientation=horizontal
android:layout_width=fill_parent
android:layout_height=wrap_content

LinearLayout
android:orientation=vertical
!-- android:layout_width=fill_parent --
android:layout_height=wrap_content
android:layout_weight=3

TextView
android:layout_width=fill_parent
android:layout_height=wrap_content
android:id=@+id/tv1
android:textColor=#FF
/
TextView
android:layout_width=fill_parent
android:layout_height=wrap_content
android:id=@+id/tv2
android:textColor=#FF
/
TextView
android:layout_width=fill_parent
android:layout_height=wrap_content
android:id=@+id/tv3
android:textColor=#FF
/
  /LinearLayout
  LinearLayout  !-- empty layout --
android:orientation=vertical
!-- android:layout_width=fill_parent --
android:layout_height=wrap_content
android:layout_weight=7

  /LinearLayout
/LinearLayout

It just my thought.. not checked in code.



On 8월20일, 오후6시09분, CMF manf...@gmail.com wrote:
 I have a linearlayout below, i want something similar to
 android:layout_width=30%
 does anyone know that?

 LinearLayout
 android:orientation=vertical
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 
 TextView
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:id=@+id/tv1
 android:textColor=#FF
 /
 TextView
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:id=@+id/tv2
 android:textColor=#FF
 /
 TextView
 android:layout_width=fill_parent
 android:layout_height=wrap_content
 android:id=@+id/tv3
 android:textColor=#FF
 /
   /LinearLayout

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout Problem

2010-05-17 Thread Anthoni
 I'll add an example of this sort of layout to my to-do list to add to
 the book. As I mentioned to somebody else earlier today, it's a long
 to-do list...

Sounds good.

One more thing wanted to ask, regarding Layouts and Themes.
I have my Application (in the AndroidManifest.xml) set to the theme
below. It draws a background picture on all my activities. However, on
a select few (about 2) I am not wanting the background to be drawn but
instead I want to implement my own view using the canvas. So what I am
wanting to know is, can I override / switch off themes in certain
activities ?

Themes.xml snippet
style name=Theme.SVP parent=android:Theme
item name=android:windowBackground@drawable/background/
item
item name=android:windowNoTitletrue/item
/style

Regards
Anthoni

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Layout Problem

2010-05-17 Thread Romain Guy
Every activity can have its own theme. Just use android:theme on the
activity / tag in your AndroidManifest.

On Sun, May 16, 2010 at 11:12 PM, Anthoni anthoni.gard...@gmail.com wrote:
 I'll add an example of this sort of layout to my to-do list to add to
 the book. As I mentioned to somebody else earlier today, it's a long
 to-do list...

 Sounds good.

 One more thing wanted to ask, regarding Layouts and Themes.
 I have my Application (in the AndroidManifest.xml) set to the theme
 below. It draws a background picture on all my activities. However, on
 a select few (about 2) I am not wanting the background to be drawn but
 instead I want to implement my own view using the canvas. So what I am
 wanting to know is, can I override / switch off themes in certain
 activities ?

 Themes.xml snippet
 style name=Theme.SVP parent=android:Theme
        item name=android:windowBackground@drawable/background/
 item
        item name=android:windowNoTitletrue/item
    /style

 Regards
 Anthoni

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Romain Guy
Android framework engineer
romain...@android.com

Note: please don't send private questions to me, as I don't have time
to provide private support.  All such questions should be posted on
public forums, where I and others can see and answer them

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout Problem

2010-05-17 Thread Anthoni
On May 17, 7:16 am, Romain Guy romain...@android.com wrote:
 Every activity can have its own theme. Just use android:theme on the
 activity / tag in your AndroidManifest.

Hi Romain,

Thanks for that, but I am actually wanting to switch the theme off so
it's just normal. Would it be enough to just tell it to render the
default android theme but I do not know how to do that.

Regards
Anthoni

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout Problem

2010-05-17 Thread Anthoni
 Thanks for that, but I am actually wanting to switch the theme off so
 it's just normal. Would it be enough to just tell it to render the
 default android theme but I do not know how to do that.

Found it, I just set my theme in the activity to @android:style/
Theme.NoTitleBar.Fullscreen and that seems to do what I want.

Regards
Anthoni

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout Problem

2010-05-16 Thread Anthoni
On May 16, 11:04 am, Mark Murphy mmur...@commonsware.com wrote:
 You do not have any layout rules to force the two widgets not to overlap.

 Move your ListView after the TableLayout the RelativeLayout definition
 in the XML, and add to it:

 android:layout_above=...

 where ... is @id/whatever_you_decide_to_call_your_table_layout,
 because you're going to need to give your TableLayout an android:id
 value. That will force it to stay above the TableLayout.

Superb as always Mark, thanks. Works perfectly.
Funny thing is I know about the layout_above tag from reading your
books, but it never occurred to me to try and use that LOL.
Guess it's just practise and practice really.

Once again thanks for the assist, much appreciated.

Regards
Anthoni

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Layout Problem

2010-05-16 Thread Mark Murphy
Anthoni wrote:
 Funny thing is I know about the layout_above tag from reading your
 books, but it never occurred to me to try and use that LOL.

I'll add an example of this sort of layout to my to-do list to add to
the book. As I mentioned to somebody else earlier today, it's a long
to-do list...

 Once again thanks for the assist, much appreciated.

No problem, happy to help!

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.5 Available!

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


[android-developers] Re: Layout problem with ListView

2009-08-15 Thread Boxy


Thanks Mark!!

I'm going to have 1 of my favorite beers while coding just for you :)

On Aug 14, 6:35 pm, Mark Murphy mmur...@commonsware.com wrote:
 Boxy wrote:

  It looks like underestimated the difficulty of this question.

  I tried to post a much simpler version of the question in the beginner
  group but its been hours and it still has not showed up.  I think they
  have a problem with new topics over there.

  I'll post the question here.  I apologize for the spam :(

  --

  I want to center a TextView inside of a layout.  I've been playing
  with the XML code below and can't get it to work?
  Please help!

  ?xml version=1.0 encoding=utf-8?
  LinearLayout xmlns:android=http://schemas.android.com/apk/res/
  android
        android:orientation=horizontal
        android:gravity=center
        android:layout_width=fill_parent
        android:layout_height=fill_parent 

        TextView
            android:id=@+id/txtMessage
            android:layout_width=fill_parent
            android:layout_height=fill_parent
            android:gravity=center /

  /LinearLayout

 Step #1: Use RelativeLayout.

 Step #2: Give the TextView the android:layout_centerInParent=true
 attribute.

 Step #3: Have a beer. Possibly preceded by root or birch, if that's
 your preference. ;-)

 --
 Mark Murphy (a Commons 
 Guy)http://commonsware.com|http://twitter.com/commonsguy

 Android Training in Germany, 18-22 January 2010:http://bignerdranch.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Layout problem with ListView

2009-08-14 Thread Boxy


It looks like underestimated the difficulty of this question.

I tried to post a much simpler version of the question in the beginner
group but its been hours and it still has not showed up.  I think they
have a problem with new topics over there.

I'll post the question here.  I apologize for the spam :(

--

I want to center a TextView inside of a layout.  I've been playing
with the XML code below and can't get it to work?
Please help!


?xml version=1.0 encoding=utf-8?
LinearLayout xmlns:android=http://schemas.android.com/apk/res/
android
  android:orientation=horizontal
  android:gravity=center
  android:layout_width=fill_parent
  android:layout_height=fill_parent 

  TextView
  android:id=@+id/txtMessage
  android:layout_width=fill_parent
  android:layout_height=fill_parent
  android:gravity=center /

/LinearLayout


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Layout problem with ListView

2009-08-14 Thread Mark Murphy

Boxy wrote:
 
 It looks like underestimated the difficulty of this question.
 
 I tried to post a much simpler version of the question in the beginner
 group but its been hours and it still has not showed up.  I think they
 have a problem with new topics over there.
 
 I'll post the question here.  I apologize for the spam :(
 
 --
 
 I want to center a TextView inside of a layout.  I've been playing
 with the XML code below and can't get it to work?
 Please help!
 
 
 ?xml version=1.0 encoding=utf-8?
 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
   android:orientation=horizontal
   android:gravity=center
   android:layout_width=fill_parent
   android:layout_height=fill_parent 
 
   TextView
   android:id=@+id/txtMessage
   android:layout_width=fill_parent
   android:layout_height=fill_parent
   android:gravity=center /
 
 /LinearLayout

Step #1: Use RelativeLayout.

Step #2: Give the TextView the android:layout_centerInParent=true
attribute.

Step #3: Have a beer. Possibly preceded by root or birch, if that's
your preference. ;-)

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://twitter.com/commonsguy

Android Training in Germany, 18-22 January 2010: http://bignerdranch.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: Layout problem with ListView

2009-08-13 Thread Boxy


Hmm it looks like my diagrams didn't post quite right to the message
board.

Just use your imagination to picture nicely drawn boxes that borders
the text :)


On Aug 13, 12:19 pm, Boxy par...@gmail.com wrote:
 First let me say that this problem is probably real easy to solve.
 But I've been looking at it all night and its got me stumped.  So to
 keep from pulling my hair out, I'll post this problem here where some
 expert can look at it for 5 seconds and figure out what I'm an
 idiot :)

 Here's the background info for what I am trying to do.  I have a
 ListView that displays text input from the user (similar to the
 Android notepad example).  I want to center the text inside a
 background image (text bubble).  I want the text bubble to be centered
 in view.

 -

                                  ---
                                  |                            |
                                  |     Hi, I'm Boxy     |
                                  |                            |
                                  ---

 -

 This is what an ideal to look like.

 Here is the code I'm using.

 LinearLayout xmlns:android=http://schemas.android.com/apk/res/
 android
     android:layout_width=fill_parent
     android:layout_height=?android:attr/listPreferredItemHeight
     android:padding=6dip
     android:gravity=center 

     LinearLayout
         android:orientation=vertical
         android:layout_width=fill_parent
         android:layout_weight=1
         android:layout_height=fill_parent
         android:gravity=center
         android:background=@drawable/textbub 

         TextView
             android:id=@+id/txtMessage
             android:layout_width=fill_parent
             android:layout_height=0dip
             android:layout_weight=1
             android:paddingLeft=40dip
             android:paddingRight=20dip
             android:gravity=center /

     /LinearLayout

 /LinearLayout

 Here is what is actually displayed by my program.

 -

      --- ---

 |
 |
      |                                 Hi, I'm
 Boxy                          |

 |
 |
      --

 -

 Above is what the first entry looks like.  Not what I want.
 Below is what the rest of the entries look like after the first.
 Definitely not what I want.

 -

       
       |                                  |
       |    What happened?   |
       |                                  |
       

 -

        
       |                                             |
       |    Why isn't this working?     |
       |                                             |
       -

 -

       ---
       |                     |
       |    This sux!   |
       |                     |
       --

 -

 So what am I doing wrong?

 Bonus Question:

 A RelativeLayout is supposed to be more efficient than a LinearLayout.
 Can I use a RelativeLayout for what I'm trying to do instead of a
 LinearLayout?
 If so, how?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---