Make views/text fit the screen on different android devices -


enter image description here

i trying make 24 hour sidebar menu. not numbers fit on every screen. know approach me fix issue numbers show

here of code on how doing right now.

single item

    <?xml version="1.0" encoding="utf-8"?> <textview xmlns:android="http://schemas.android.com/apk/res/android"           android:id="@+id/car_history_sidemenu_item"           android:layout_width="wrap_content"           android:layout_height="wrap_content"           android:gravity="center"           android:padding="3dp"            android:textsize="14sp" /> 

the layout

<?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" >      <relativelayout       android:layout_width="match_parent"       android:layout_height="match_parent"       android:orientation="vertical"       android:layout_alignparentbottom="true">           <relativelayout             android:id="@+id/car_history_map_content"             android:layout_width="wrap_content"             android:layout_height="match_parent"             android:layout_tostartof="@+id/history_side_index"             android:layout_toleftof="@+id/history_side_index"             android:layout_alignparenttop="true"             android:layout_alignparentleft="true"             android:layout_alignparentstart="true"             android:layout_alignparentbottom="true">           </relativelayout>          <linearlayout             android:id="@+id/history_side_index"             android:background="#c3c3c3"             android:orientation="vertical"              android:layout_width="wrap_content"             android:layout_height="fill_parent"             android:gravity="center"             android:padding="3dp"             android:textsize="14sp"               android:layout_alignparentright="true"             android:layout_alignparentend="true"             android:layout_alignparenttop="true">         </linearlayout>     </relativelayout> </relativelayout> 

code

  protected void setupfastscrolllist()   {     linearlayout linearlayout;     linearlayout = (linearlayout) findviewbyid(r.id.history_side_index);      textview textview;      for(int = 0; < 24; i++)     {       textview = (textview) getlayoutinflater().inflate(r.layout.car_history_sidemenu_item,null);       textview.settext("" + i);       linearlayout.addview(textview);     }   } 

do have scale on runtime or there smart way xml automatically scale numbers fit on every device screen.

please read google's article supporting multiple screens.

stable link: http://developer.android.com/guide/practices/screens_support.html


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -