How to resize TextView with SeekBar's progress (Android) -
i'm triying change text size of textview using seekbar, , it's works fine when increase size, when decrease, "text size" changes well, "textview's layout" seems have biggest height put (the text appears in center of layout if has match_parent property instead of wrap_content).
i tried many combinations of textview's layout properties (it's in relativelayout) (h:wrap_cont,w:wrap_cont / h:match_par,w:match_par,aling parent top true /.....)
can me??
edit: textview should appear on top
layout
<linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <relativelayout android:id="@+id/preview_preview" android:layout_width="match_parent" android:layout_height="match_parent" > <imageview android:id="@+id/preview_image" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/cuadros_001"/> <textview android:id="@+id/preview_text_top" android:layout_width="match_parent" android:layout_height="match_parent" android:text="textview" android:textcolor="#ffffff"/> <textview android:id="@+id/preview_text_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="2.5dp" android:gravity="bottom|center" android:text="preview_text_bottom" android:textcolor="#ffffff" android:textsize="25dp" android:layout_alignparentbottom="true" android:layout_centerhorizontal="true"/> </relativelayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <gridview android:id="@+id/preview_gridview" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/backgroundtransparencia" android:gravity="center" android:horizontalspacing="5dp" android:numcolumns="3" android:stretchmode="columnwidth" android:verticalspacing="10dp" > </gridview> </linearlayout> <linearlayout android:id="@+id/preview_child_2" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" /> <button android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" /> </linearlayout> </viewflipper>
---seekbar--
seekbar_toptext =(seekbar)findviewbyid(r.id.seekbar_toptext); seekbar_toptext.setprogress(40); seekbar_toptext.incrementprogressby(05); seekbar_toptext.setmax(100); seekbar_toptext.setonseekbarchangelistener(new onseekbarchangelistener() { int topsize; public void onstoptrackingtouch(seekbar seekbar) { // todo auto-generated method stub } public void onstarttrackingtouch(seekbar seekbar) { // todo auto-generated method stub } public void onprogresschanged(seekbar seekbar, int progress, boolean fromuser) { preview_text_top.settextsize(typedvalue.complex_unit_sp ,progress); } });
thanks in advance.
try code...
i hope helps you...
final textview t1=new textview(this); t1.settext("hello android"); final seekbar sk=(seekbar) findviewbyid(r.id.seekbar1); sk.setonseekbarchangelistener(new onseekbarchangelistener() { @override public void onstoptrackingtouch(seekbar seekbar) { // todo auto-generated method stub } @override public void onstarttrackingtouch(seekbar seekbar) { // todo auto-generated method stub } @override public void onprogresschanged(seekbar seekbar, int progress,boolean fromuser) { // todo auto-generated method stub t1.settextsize(progress); toast.maketext(getapplicationcontext(), string.valueof(progress),toast.length_long).show(); } });
Comments
Post a Comment