Android layouts view scrolable texts in a page with other buttons -


i new @ android , try make page scrollable texts. using relative layout linear layout , scroll. somehow texts not paint begining.

the first 3 lines not drawn (title1,title2, title3) because outside scroll area. why? scroll works/shows fine in specified area 2 buttons below: set here android:layout_below="@id/button_s" android:layout_above="@id/button_c" margins of scroll still text displays outside margins. wrong? why linear layout lin2 in draw texts starts top of screen? set android:layout_below.

here code:

main.xml:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:id="@+id/relative_layout"     android:layout_width="fill_parent"     android:layout_height="fill_parent">   <textview     android:id="@+id/tv"     android:layout_width="fill_parent"     android:layout_height="wrap_content"     android:layout_alignparenttop="true"     android:text="@string/my_app" />  <button     android:id="@+id/button_s"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentright="true"     android:layout_below="@id/tv"     android:text="@string/search" />     <button     android:id="@+id/button_c"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentright="true"     android:layout_alignparentbottom="true"     android:text="@string/config" />  <scrollview xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="fill_parent"     android:layout_height="wrap_content"      android:scrollbars="vertical"     android:layout_below="@id/button_s"     android:layout_above="@id/button_c" android:id="@+id/scrollview">      <linearlayout         android:layout_width="fill_parent"                               android:orientation="vertical"         android:id="@+id/lin2"          android:layout_height="wrap_content"           android:layout_below="@id/button_s"         android:layout_above="@id/button_c"         android:layout_gravity="center_vertical|center_horizontal">      </linearlayout> </scrollview>   </relativelayout> 

my java file:

string[] strtitles  ={"title 1: test test test test test test test test",                        "title 2:  test test test test test",                        "title 3:  test test test test test",                        "title 4:  test test test test",                        "title 5:  test test test",                        "title 6:  test test test test",                        "title 7:  test test test test",                        "title 8:  test test test test test",                        "title 9:  test test test test test",                        "title 9:  test test test test test",                        "title 10:  test test test test",                        "title 11:  test test test test test",                        "title 12:  test test test test test",                        "title 13:  test test test test test",                        "title 14:  test test "}; /** called when activity first created. */ @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);      linearlayout ll = (linearlayout)findviewbyid(r.id.lin2);      (int = 0 ; < strtitles.length * 2 ; i++)     {         string strtodisplay = " ";         if(i%2 == 1)             strtodisplay = " ";         else         {             strtodisplay = strtitles[i/2];         }          textview tv = new textview(this);         tv.settext(strtodisplay);         ll.addview(tv);         tv.setgravity(gravity.center_vertical | gravity.center_horizontal);      }     } 

thanks

change layout_gravity center_horizontal lin2 linearlayout:

android:layout_gravity="center_horizontal" 

i don't understand why put center_vertical when parent scrollview height set wrap_content.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -