android - How To Use HorizontalScrollView Only When Needed -



android - How To Use HorizontalScrollView Only When Needed -

i displaying text , images in listview horizontalscrollview if text , images long screen size thought there if needed.

but when there no need horizontalscrollview cause text , images fit in screen still appears every row , in tabs makes swiping tab tab irritating cause finger catches horizontalscrollview , not whole tab.

and textviews ect... in 1 layout file can't take rows.

<horizontalscrollview android:layout_width="wrap_content" android:layout_height="wrap_content" xmlns:android="http://schemas.android.com/apk/res/android"> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center_vertical" android:orientation="horizontal" > <textview android:id="@+id/textview1" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview1" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview2" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview2" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview3" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview3" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview4" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview4" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview5" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview5" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview6" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview6" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> <textview android:id="@+id/textview7" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:textsize="14sp" android:textstyle="bold" /> <imageview android:id="@+id/imageview7" android:layout_marginstart="5dp" android:layout_marginleft="5dp" android:layout_marginright="5dp" android:layout_margintop="10dp" android:layout_marginbottom="10dp" android:layout_width="30dp" android:layout_height="30dp"/> </linearlayout> </horizontalscrollview> view v=infla.inflate(r.layout.main_tab_layout, null); textview tv1=(textview)v.findviewbyid(r.id.textview1); imageview iv1=(imageview)v.findviewbyid(r.id.imageview1); textview tv2=(textview)v.findviewbyid(r.id.textview2); imageview iv2=(imageview)v.findviewbyid(r.id.imageview2); tv1.settext(text1[position]); iv1.setimageresource(text2[position]); tv2.settext(text3[position]); iv2.setimageresource(text4[position]); if(text3[position].matches("")) { tv2.setvisibility(view.gone); } if(text4[position]==r.drawable.ic_star){ iv2.setvisibility(view.gone); } homecoming v; }

you not hiding imageviews. there no drawable on them why looks there nil there since width , height hardcoded, take space.

set visibility gone imageviews not beingness used.

android scrollview android-linearlayout

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -