| Author |
Message |
x-files Developer

Joined: 11 Jan 2008 Posts: 44
|
Posted: Wed Jan 23, 2008 5:05 pm Post subject: Interval between two neighboring items inside LinearLayout |
|
|
| 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 |
|
 |
|
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Thu Jan 24, 2008 3:29 am Post subject: |
|
|
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 |
|
 |
x-files Developer

Joined: 11 Jan 2008 Posts: 44
|
Posted: Thu Jan 24, 2008 9:36 am Post subject: |
|
|
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 |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Thu Jan 24, 2008 12:00 pm Post subject: |
|
|
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 |
|
 |
cabernet1976 Senior Developer

Joined: 16 Nov 2007 Posts: 154 Location: China
|
Posted: Thu Jan 24, 2008 12:45 pm Post subject: |
|
|
It is a part of my program, must work fine. Just try it.
_________________ Upload2Flickr's blog: http://upload2flickr.blogspot.com |
|
| Back to top |
|
 |
AndreySerj Developer

Joined: 26 Dec 2007 Posts: 28 Location: Minsk
|
Posted: Mon Jan 28, 2008 10:36 am Post subject: |
|
|
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 |
|
 |
|
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
Posted: Mon Jan 28, 2008 3:22 pm Post subject: |
|
|
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.
Regards,
plusminus
_________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
AndreySerj Developer

Joined: 26 Dec 2007 Posts: 28 Location: Minsk
|
Posted: Mon Jan 28, 2008 3:31 pm Post subject: |
|
|
| 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 |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
Posted: Mon Jan 28, 2008 3:55 pm Post subject: |
|
|
Hello AndreySerj,
so if this ...
isn't what you want to do, I missunderstood you
Could you rephrase your question
Regards,
plusminus
_________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
AndreySerj Developer

Joined: 26 Dec 2007 Posts: 28 Location: Minsk
|
Posted: Mon Jan 28, 2008 4:09 pm Post subject: |
|
|
Hello, plusminus
I mean this ...
| Description: |
|
| Filesize: |
19.5 KB |
| Viewed: |
4119 Time(s) |

|
|
|
| Back to top |
|
 |
plusminus Site Admin


Joined: 14 Nov 2007 Posts: 2660 Location: College Park, MD
|
Posted: Tue Jan 29, 2008 1:47 pm Post subject: |
|
|
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
_________________
Download my apps  Please remember, that this board is give & take 
| Android Development Community / Tutorials |
|
| Back to top |
|
 |
zeeshan Experienced Developer

Joined: 03 Mar 2008 Posts: 68
|
Posted: Mon Apr 07, 2008 5:59 am Post subject: |
|
|
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 |
|
 |
ramgraph1 Experienced Developer

Joined: 09 Jan 2008 Posts: 68
|
Posted: Mon Apr 07, 2008 2:00 pm Post subject: |
|
|
| 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 |
|
 |
zeeshan Experienced Developer

Joined: 03 Mar 2008 Posts: 68
|
Posted: Mon Apr 07, 2008 2:02 pm Post subject: |
|
|
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 |
|
 |
|