2

이 탭 표시기 구조 (화면은 노바 실행기에서 제공됨)를 재현하려면 드롭 다운 메뉴와 오른쪽 하단 모서리에있는 화살표를 사용하십시오.사용자 정의 탭 표시기보기

enter image description here

나는 코드에 대한 아무 문제가 없지만 나는이 모습을 재현 할 수 있습니다. 나는이 시도 : mbar에서 셜록 지원 액션 바입니다

mBar.addTab(mBar.newTab().setText(ctx.getString(R.string.tab_actions)).setTabListener(this).setCustomView(R.layout.navigation_spinner)); 

.

내 레이아웃입니다 :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout android:layout_width="match_parent" 
    android:layout_height="match_parent" android:layout_margin="-10dp" 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical"> 
    <Button android:id="@+id/button1" android:layout_width="match_parent" 
     android:layout_height="match_parent" android:text="Button" /> 

</LinearLayout> 

이 내 결과입니다

enter image description here

문제는 중앙 탭에서 버튼을 탭 표시를 기입하지 않습니다. 마진이나 패딩없이 표시기를 완벽하게 채우는 사용자 정의보기를 설정하려면 어떻게해야합니까? 아니면 전나무 화면과 같은 결과를 얻으려면 다른 방식으로이 접근해야합니까? 조언에 감사드립니다

답변

0

당신이하려는 것은 실제로 복잡하고 달성하기 어려울 것입니다. 당신이 드롭 다운 메뉴를 원하는 경우

당신은 그 시도 할 수 있습니다 :

메뉴/options.xml :

<item 
    android:icon="@drawable/ic_menu_sort" 
    android:showAsAction="ifRoom"> 
    <menu> 
     <item 
      android:id="@+id/menuSortNewest" 
      android:title="Sort by newest" /> 
     <item 
      android:id="@+id/menuSortRating" 
      android:title="Sort by rating" /> 
    </menu> 
</item> 

두 번째 옵션 :

메뉴/options.xml :

<menu xmlns:android="http://schemas.android.com/apk/res/android"> 
    <item 
     android:id="@+id/menuSort" 
     android:showAsAction="ifRoom" 
     android:actionLayout="@layout/action_sort" /> 
</menu> 

레이아웃/action_sort.xml :

<Spinner xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:background="@drawable/ic_menu_refresh" 
    android:entries="@array/order" /> 

메뉴 리소스 용 문서 - http://developer.android.com/guide/topics/resources/menu-resource.html