Interval between two neighboring items inside LinearLayout

Put your problem here if it does not fit any of the other categories.

Interval between two neighboring items inside LinearLayout

Postby x-files » Wed Jan 23, 2008 5:05 pm

I have a LinearLayout. Initially it is empty. Then I add to it several TextView components via its addView() method. How can I set interval (marging) between two neighboring TextView components ?
x-files
Developer
Developer
 
Posts: 44
Joined: Fri Jan 11, 2008 10:27 am

Top

Postby cabernet1976 » Thu Jan 24, 2008 3:29 am

If your LinearLayout is vertical, please use:
android:layout_marginBottom="Xdip" and/or android:layout_marginTop="Xdip"

Else if your LinearLayout is horizontal, please use:
android:layout_marginLeft="Xdip" and/or android:layout_marginRight="Xdip"

X is a number, e.g. 3

It should work.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby x-files » Thu Jan 24, 2008 9:36 am

it isn't work.

android:layout_marginBottom - specifies extra space on the bottom side of this view.

I need to add extra space between chield of LinearLayout.
x-files
Developer
Developer
 
Posts: 44
Joined: Fri Jan 11, 2008 10:27 am

Postby cabernet1976 » Thu Jan 24, 2008 12:00 pm

Sorry for I didn't describe it clear, your should add those parameters to the widgets. Those parameters means the widget/(also for layout) will have a interval with its neighbor.
e.g.

Syntax: [ Download ] [ Hide ]
Using xml Syntax Highlighting
  1.  
  2.     <LinearLayout id="@+id/buttonbar"
  3.  
  4.        xmlns:android="http://schemas.android.com/apk/res/android"
  5.  
  6.        android:orientation="horizontal"
  7.  
  8.        android:layout_width="fill_parent"
  9.  
  10.        android:layout_height="wrap_content" >
  11.  
  12.    
  13.  
  14.         <Button id="@+id/cancel"
  15.  
  16.            android:text="@string/cancel"
  17.  
  18.            android:layout_marginLeft="4dip"
  19.  
  20.            android:layout_marginRight="2dip"
  21.  
  22.            android:layout_width="fill_parent"
  23.  
  24.            android:layout_height="wrap_content"
  25.  
  26.            android:layout_weight="1"
  27.  
  28.            android:layout_centerVertical="true" />
  29.  
  30.  
  31.  
  32.         <Button id="@+id/ok"
  33.  
  34.            android:text="@string/ok"
  35.  
  36.            android:layout_marginLeft="2dip"
  37.  
  38.            android:layout_marginRight="4dip"
  39.  
  40.            android:layout_width="fill_parent"
  41.  
  42.            android:layout_height="wrap_content"
  43.  
  44.            android:layout_weight="1"
  45.  
  46.            android:layout_centerVertical="true" />
  47.  
  48.     </LinearLayout>
  49.  
  50.  
Parsed in 0.003 seconds, using GeSHi 1.0.8.4
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby cabernet1976 » Thu Jan 24, 2008 12:45 pm

It is a part of my program, must work fine. Just try it.
Upload2Flickr's blog: http://upload2flickr.blogspot.com
cabernet1976
Senior Developer
Senior Developer
 
Posts: 154
Joined: Fri Nov 16, 2007 2:34 am
Location: China

Postby AndreySerj » Mon Jan 28, 2008 10:36 am

I have a like issue.
MyActivity extends ListActivity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public class MyActivity extends ListActivity {
  3.  
  4.  
  5.  
  6.     @Override
  7.  
  8.     public void onCreate(Bundle icicle) {
  9.  
  10.         super.onCreate(icicle);
  11.  
  12.         setContentView(R.layout.mylist);
  13.  
  14.         ....
  15.  
  16.         setListAdapter(...);
  17.  
  18.         ....
  19.  
  20.     }
  21.  
  22.  
  23.  
  24.  .....
  25.  
  26.  
  27.  
  28. }
  29.  
  30.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


mylist.xml:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
  4.         android:layout_width="fill_parent"
  5.  
  6.         android:layout_height="fill_parent">
  7.  
  8.    
  9.  
  10.     <ListView id="@+id/android:list"
  11.  
  12.                 android:layout_width="fill_parent"
  13.  
  14.                 android:layout_height="wrap_content"/>
  15.  
  16.                
  17.  
  18.         <TextView id="@+id/android:empty"
  19.  
  20.                 android:layout_width="fill_parent"
  21.  
  22.                 android:layout_height="wrap_content"
  23.  
  24.                 android:text="Nothing!"/>
  25.  
  26. </LinearLayout>
  27.  
  28.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


How can I set interval between two neighboring lines into this list?
AndreySerj
Developer
Developer
 
Posts: 31
Joined: Wed Dec 26, 2007 9:57 am
Location: Minsk

Top

Postby plusminus » Mon Jan 28, 2008 3:22 pm

Hey guys,

you can do that by calling setPadding(int,int,int,int); or in xml via "...android:paddingBottom="4px"...":

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. <span style="font-weight: bold"> public void setPadding(int left, int top, int right, int bottom)</span>
  2.  
  3. Sets the padding.
  4.  
  5. Related XML Attributes
  6.  
  7.  
  8.  
  9.     * android:padding
  10.  
  11.     * android:paddingBottom
  12.  
  13.     * android:paddingLeft
  14.  
  15.     * android:paddingRight
  16.  
  17.     * android:paddingTop
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


The padding is expressed in pixels for the left, top, right and bottom parts of the view. Padding can be used to offset the content of the view by a specific amount of pixels. For instance, a left padding of 2 will push the view's content by 2 pixels to the right of the left edge. Padding can be set using the setPadding(int, int, int, int) method and queried by calling getPaddingLeft(), getPaddingTop(), getPaddingRight() and getPaddingBottom().


Hope I could help you. :)

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby AndreySerj » Mon Jan 28, 2008 3:31 pm

plusminus wrote:Hey guys,

you can do that by calling setPadding(int,int,int,int); or in xml via "...android:paddingBottom="4px"..."


Hi plusminus, I tried do it... Such paddings attributes change an interval between text lines into one item of list, but not between two neighboring items of list It can see if items of list have a background.
Last edited by AndreySerj on Mon Jan 28, 2008 3:58 pm, edited 1 time in total.
AndreySerj
Developer
Developer
 
Posts: 31
Joined: Wed Dec 26, 2007 9:57 am
Location: Minsk

Postby plusminus » Mon Jan 28, 2008 3:55 pm

Hello AndreySerj,

so if this ...
[align=center]Image[/align]

isn't what you want to do, I missunderstood you :?
Could you rephrase your question :?:

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby AndreySerj » Mon Jan 28, 2008 4:09 pm

Hello, plusminus
I mean this ...
Attachments
listview_padding.png
listview_padding.png (19.5 KiB) Viewed 12143 times
AndreySerj
Developer
Developer
 
Posts: 31
Joined: Wed Dec 26, 2007 9:57 am
Location: Minsk

Postby plusminus » Tue Jan 29, 2008 1:47 pm

Hello AndreySerj,

tried some minutes, but couldn't find the appropriate xml-tag for this :(
Perhaps it is not possible with a default ArrayAdapter :?

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby zeeshan » Mon Apr 07, 2008 5:59 am

hello plusminus,
Means its not possible in current android sdk or what is there any solution for this ???

Waiting for your reply ?
zeeshan
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Mon Mar 03, 2008 6:10 am

Postby ramgraph1 » Mon Apr 07, 2008 2:00 pm

For what it's worth, as I could find no coding solution to this, I have been using empty TextViews to create this kind of empty space between objects. It does what I want but I am not sure what pitfalls doing it that way might have...
ramgraph1
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Wed Jan 09, 2008 10:03 pm

Postby zeeshan » Mon Apr 07, 2008 2:02 pm

have u used


od = (ListView)findViewById(android.R.id.list);
od.setDividerHeight(15);


this i have some what achieved this please have a look at this ..


now i want to draw a white border on each listview item ...

any idea about that?
zeeshan
Experienced Developer
Experienced Developer
 
Posts: 68
Joined: Mon Mar 03, 2008 6:10 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests