Android: Top and bottom padding of text in listview item -


i developing application in using custom list view. xml code follows :

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:background="@drawable/loginbg" >      <relativelayout         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_margin="15sp"         android:background="@android:color/white" >          <listview             android:id="@+id/listview"             android:layout_width="fill_parent"             android:layout_height="fill_parent"             android:divider="#000000"             android:dividerheight=".5sp" >         </listview>     </relativelayout>  </relativelayout> 

and custom adapter xml :

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <textview          android:id="@+id/textview"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:paddingtop="75sp"         android:paddingbottom="75sp"         android:gravity="center"         android:textsize="20sp"         android:textcolor="@android:color/white" />  </relativelayout> 

but out put not needed. needed vertical padding of text given in adapter textview in xml.

my out put is:

output

i need space top , bottem of text in text view in adapter of list view.

i tried .java file :

textview.setpadding(0, 75, 0, 75); 

but of no use.

i need output :

enter image description here

please guide me should now.

you don't need top , bottom then, check this:

<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="fill_parent" >      <textview         android:id="@+id/textviewn_company_clsa"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:gravity="center"         android:padding="75dp"         android:text="asdf"         android:textcolor="@android:color/white"         android:textsize="20sp" />  </relativelayout>   

for custom layout, inside textview, use margintop , marginbottom (or layout_margin)which give space outside textview's container.

padding provides space within container. listview item, need space outside each row/item also.

check:
android beginner difference between padding , margin
difference between view's padding , margin

android:paddingtop="75sp" android:paddingbottom="75sp"   

and

android:layout_margin="15sp"   android:dividerheight=".5sp"  

unit needs in "dp"..:

android:paddingtop="75dp" android:paddingbottom="75dp"  

and

android:layout_margin="15dp"   android:dividerheight=".5dp"   

for ref:
what difference between "px", "dp", "dip" , "sp" on android?
http://www.prandroid.com/2013/03/differences-between-px-dip-dp-and-sp.html


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -