andbook!.pdf - Learning Android Get an anddev.org - Android-Shirt Back to index
anddev.org Header Logo
FAQ Search Top rated articles Browse Feeds anddev.org - Authors Contact Details Register Log in

Interval between two neighboring items inside LinearLayout


 
       anddev.org - Android Development Community | Android Tutorials | Index -> Other Coding-Problems
Author Message
x-files
Developer
Developer


Joined: 11 Jan 2008
Posts: 44

PostPosted: Wed Jan 23, 2008 5:05 pm    Post subject: Interval between two neighboring items inside LinearLayout Reply with quote

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 ?
Back to top
View user's profile Send private message
cabernet1976
Senior Developer
Senior Developer


Joined: 16 Nov 2007
Posts: 154
Location: China

PostPosted: Thu Jan 24, 2008 3:29 am    Post subject: Reply with quote

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
Back to top
View user's profile Send private message Visit poster's website
x-files
Developer
Developer


Joined: 11 Jan 2008
Posts: 44

PostPosted: Thu Jan 24, 2008 9:36 am    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
cabernet1976
Senior Developer
Senior Developer


Joined: 16 Nov 2007
Posts: 154
Location: China

PostPosted: Thu Jan 24, 2008 12:00 pm    Post subject: Reply with quote

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.

XML:

    <LinearLayout id="@+id/buttonbar"
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

   
        <Button id="@+id/cancel"
            android:text="@string/cancel"
            android:layout_marginLeft="4dip"
            android:layout_marginRight="2dip"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_centerVertical="true" />


        <Button id="@+id/ok"
            android:text="@string/ok"
            android:layout_marginLeft="2dip"
            android:layout_marginRight="4dip"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:layout_centerVertical="true" />

    </LinearLayout>

_________________
Upload2Flickr's blog: http://upload2flickr.blogspot.com
Back to top
View user's profile Send private message Visit poster's website
cabernet1976
Senior Developer
Senior Developer


Joined: 16 Nov 2007
Posts: 154
Location: China

PostPosted: Thu Jan 24, 2008 12:45 pm    Post subject: Reply with quote

It is a part of my program, must work fine. Just try it.
_________________
Upload2Flickr's blog: http://upload2flickr.blogspot.com
Back to top
View user's profile Send private message Visit poster's website
AndreySerj
Developer
Developer


Joined: 26 Dec 2007
Posts: 28
Location: Minsk

PostPosted: Mon Jan 28, 2008 10:36 am    Post subject: Reply with quote

I have a like issue.
MyActivity extends ListActivity:
Java:

public class MyActivity extends ListActivity {

    @Override
    public void onCreate(Bundle icicle) {
     super.onCreate(icicle);
     setContentView(R.layout.mylist);
        ....
        setListAdapter(...);
        ....
    }
 
 .....

}


mylist.xml:
Java:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
     android:layout_height="fill_parent">
   
    <ListView id="@+id/android:list"
               android:layout_width="fill_parent"
          android:layout_height="wrap_content"/>
         
     <TextView id="@+id/android:empty"
               android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Nothing!"/>
</LinearLayout>


How can I set interval between two neighboring lines into this list?
Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Mon Jan 28, 2008 3:22 pm    Post subject: Reply with quote

Hey guys,

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

Java:
[b] public void setPadding(int left, int top, int right, int bottom)[/b]
Sets the padding.
Related XML Attributes

    * android:padding
    * android:paddingBottom
    * android:paddingLeft
    * android:paddingRight
    * android:paddingTop


Quote:
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. Smile

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AndreySerj
Developer
Developer


Joined: 26 Dec 2007
Posts: 28
Location: Minsk

PostPosted: Mon Jan 28, 2008 3:31 pm    Post subject: Reply with quote

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
Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Mon Jan 28, 2008 3:55 pm    Post subject: Reply with quote

Hello AndreySerj,

so if this ...


isn't what you want to do, I missunderstood you Confused
Could you rephrase your question Question

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
AndreySerj
Developer
Developer


Joined: 26 Dec 2007
Posts: 28
Location: Minsk

PostPosted: Mon Jan 28, 2008 4:09 pm    Post subject: Reply with quote

Hello, plusminus
I mean this ...



listview_padding.png
 Description:
 Filesize:  19.5 KB
 Viewed:  4119 Time(s)

listview_padding.png


Back to top
View user's profile Send private message
plusminus
Site Admin
Site Admin


Joined: 14 Nov 2007
Posts: 2660
Location: College Park, MD

PostPosted: Tue Jan 29, 2008 1:47 pm    Post subject: Reply with quote

Hello AndreySerj,

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

Regards,
plusminus

_________________
Download my apps Idea
Please remember, that this board is give & take Smile


| Android Development Community / Tutorials
Back to top
View user's profile Send private message Send e-mail Visit poster's website
zeeshan
Experienced Developer
Experienced Developer


Joined: 03 Mar 2008
Posts: 68

PostPosted: Mon Apr 07, 2008 5:59 am    Post subject: Reply with quote

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

Waiting for your reply ?
Back to top
View user's profile Send private message
ramgraph1
Experienced Developer
Experienced Developer


Joined: 09 Jan 2008
Posts: 68

PostPosted: Mon Apr 07, 2008 2:00 pm    Post subject: Reply with quote

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...
Back to top
View user's profile Send private message
zeeshan
Experienced Developer
Experienced Developer


Joined: 03 Mar 2008
Posts: 68

PostPosted: Mon Apr 07, 2008 2:02 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
       anddev.org - Android Development Community | Android Tutorials | Index -> Other Coding-Problems All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


© 2007, Android Development Community
All rights reserved.
Powered by phpBB.