2012-07-07 3 views
0

SeekBar를 사용하여 TextView의 텍스트 크기를 변경하려고 시도 중입니다. 크기를 늘리면 "텍스트 크기"가 잘 바뀝니다. 그러나 "textview의 레이아웃"은 가장 큰 높이를 가진 것처럼 보입니다 (텍스트는 레이아웃 중앙에 wrap_content 대신 match_parent 속성이있는 것처럼 나타납니다). (: WRAP_CONT, W : WRAP_CONT/H : MATCH_PAR, W : MATCH_PAR, TRUE ALING 상위 TOP/..... H)SeekBar의 진행 상태로 TextView의 크기를 조정하는 방법 (안드로이드)

I는 텍스트 뷰의 레이아웃 속성 (그것은 RelativeLayout의에 'S) 많은 조합을 시도

누군가 나를 도울 수 있습니까 ??

편집 : 텍스트 뷰는

<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); 

     } 
    }); 

사전에 감사합니다.

+0

['forceLayout()'(http://developer.android.com/를 호출 시도 reference/android/view/View.html # forceLayout())를 TextView와 그 부모 모두에 적용합니다. –

+0

나는 노력했지만 저를 위해 일하지 않습니다. = / – KNU

답변

0

이 코드를 사용해보십시오 ...이 의지가 당신에게 도움이되기를 바랍니다

...

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(); 

    }  
});    
관련 문제