2017-11-13 2 views
0

탭에서 설정하는 두 조각으로 작업하고 있습니다.여러 줄 제목이있는 탭에 단편 설정

  1. 내가 대신 멀티 라인 조각의 제목을 설정하려면 "..."

여기에 추가하는 코드입니다 :

enter image description here

나는이 문제가 조각을 만들고 제목을 정한다.

ViewPagerAdapter adapter = new ViewPagerAdapter(getSupportFragmentManager()); 
    adapter.addFragment(new OneFragment(), "Current\nSubscription"); 
  1. 아이콘을 둘러싼 여분의 공간을 제거하고 탭의 텍스트를 압축하여 공간을 절약하고 싶습니다.

답변

0

난 당신이 스크롤에 tabmode를 설정해야하는 것이 좋습니다 좋은 UI 경험을하고 탭을 못하게 탭 제목에 "..."이 코드

TextView tabOne = new TextView(this); 
tabOne.setText("Current"+ System.getProperty("line.separator") +"Subscription"); 
tabOne.setCompoundDrawablesWithIntrinsicBounds(0, R.drawable.ic_tab_favourite, 0, 0); 
tabLayout.getTabAt(0).setCustomView(tabOne); 
0

개 표시 이하로 사용하여 TabLayout 제목을 설정하십시오 제목은 원하는만큼 공간을 차지합니다.

<android.support.design.widget.TabLayout 
       android:id="@+id/htab_tabs" 
       android:layout_width="wrap_content" 
       android:layout_height="?attr/actionBarSize" 
       android:layout_gravity="bottom" 
       app:tabIndicatorColor="@android:color/white" 
       app:tabMode="scrollable" /> 
+0

로이드 : "ATTR/actionBarSize"는 layout_height = actionBarSize의 높이를 설정 모든 불필요한 공간을 제거 하였다. 감사합니다 – pamo

+0

당신이 다음에 수동으로 56.0dip Dilip

+0

처럼 수동으로 정의 할 수 없다면 액션 바 높이입니다. 그렇지 않으면 android : layout_height = "? attr/actionBarSize"this with android : layout_height = "56.0dip" – Dilip

관련 문제