2014-01-30 1 views
1

탭 호스트의 제목을 두 줄로 설정해야합니다. 탭을 선택할 때 자동 스크롤 가능한 것으로 볼 수있는 전체 텍스트가 표시되고 있지만 두 줄로 표시해야 항상 볼 수 있습니다. 아무도 도와주세요!TabHost 제목 이름을 두 줄로 설정하는 방법

public class Tabs extends Activity implements OnClickListener { 
TabHost th; 


@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // TODO Auto-generated method stub 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.tabs); 
    th = (TabHost) findViewById(R.id.tabhost); 



    th.setup(); 
    TabSpec specs = th.newTabSpec("tag1"); 
    specs.setContent(R.id.tab1); 
    specs.setIndicator("Large Text"); 

//That is i need to put "Large" in one line and "Text" in next line in the title of the tabhost  

    th.addTab(specs); 

    specs = th.newTabSpec("tag2"); 
    specs.setContent(R.id.tab2); 
    specs.setIndicator("Small"); 
    th.addTab(specs); 

    specs = th.newTabSpec("tag3"); 
    specs.setContent(R.id.tab3); 
    specs.setIndicator("TEXT"); 
    th.addTab(specs); 

    specs = th.newTabSpec("tag4"); 
    specs.setContent(R.id.tab4); 
    specs.setIndicator("TXET"); 
    th.addTab(specs); 

} 

@Override 
public void onClick(View v) { 
    // TODO Auto-generated method stub 

} 

} 첫째

답변

0

, 나는 탭 이름에 긴 텍스트를 설정 낙담 당신을 말할 것이다. 탭 제목은 짧고 쉽게 이해할 수있는 설명을 제공하기 위해 작성되었으며 긴 텍스트로 이름을 설정하면 사용자가 복잡해 질 수 있습니다.

하나의 접근법은 두 개의 개별 TextView을 구현하거나 두 번째로 maxLines 속성을 2으로 설정하는 새로운 레이아웃을 정의하는 것입니다. 이 방법, 당신이 할 수 단순히 inflate과 같이 수행하여 탭 :

final View view = LayoutInflater.from(context).inflate(R.layout.your_new_tab_layout, null); 
TextView tv = view.findViewById(R.id.your_double_line_textview); 
tv.setText("First line\nSecond line); 
: 두 번째 방법을 사용하여,

final View view = LayoutInflater.from(context).inflate(R.layout.your_new_tab_layout, null); 
TextView tv1 = view.findViewById(R.id.your_first_line_textview); 
TextView tv2 = view.findViewById(R.id.your_second_line_textview); 
tv1.setText("My first line"); 
tv2.setText("My second line"); 

또는