2014-03-03 3 views
0

내 질문은 TABCONTENT 앞에 반쪽 이미지 또는 선택한 TAB 만 표시하려는 것입니다. 선형 레이아웃 부모 태그 안에 tabcontent를 위해 TabWidget과 FrameLayout을 사용했습니다. Framelayout을 부모 레이아웃으로 사용할 수는 있지만 탭 위젯은 숨겨져 있다는 것을 알고 있습니다. 나는 코드를 붙이고 있습니다. 제발 저에게 제안을 해주세요.TabContent 앞에 TabWidget 배경 이미지를 가져 오는 방법

enter image description here

여기 당신은 내가 tabcontent의 일부입니다 위의 이미지 아래이 화살표를 표시 할 탭의 화살표를 선택 볼 수 있습니다.

<TabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/txt_floor" 
    android:background="@color/app_bg" > 
    <LinearLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" 
     android:orientation="vertical" > 
     <TabWidget 
      android:id="@android:id/tabs" 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:showDividers="none" 
      android:dividerPadding="0dp" 
      android:tabStripEnabled="false" /> 
      <FrameLayout 
       android:id="@android:id/tabcontent" 
       android:layout_width="0dp" 
       android:layout_height="0dp" 
       android:layout_marginTop="-5dp" 
       android:layout_weight="0" /> 

       <android.support.v4.view.ViewPager 
        android:id="@+id/viewpager" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:layout_marginTop="0dp" 
        android:layout_weight="0" 
        android:layout_gravity="bottom" /> 
     </LinearLayout> 
</TabHost> 
+0

제거'안드로이드 : layout_marginTop = "- 5dp은"'에서'나는 이미지 위에서 선택한 탭의 화살표를 표시 할 –

+0

FrameLayout'. 여백을 제거하면 전체 이미지가 표시되지만 이미지는 표시되지 않습니다. –

+0

그러면 가장 좋은 방법은'LinearLayout' 대신'RelativeLayout'입니다 –

답변

0

더 많은 검색을 한 후에 매력적으로 느껴지는이 솔루션을 발견했습니다. 희망이 솔루션은 다른 사람들에게 도움이되기를 바랍니다. enter image description here

<TabHost 
    android:id="@android:id/tabhost" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:layout_below="@+id/txt_hosp_name" 
    android:background="@color/app_bg" > 


     <FrameLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:orientation="vertical" > 

      <FrameLayout 
       android:id="@+id/content_framelayout" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_gravity="bottom" > 

       <FrameLayout 
        android:id="@android:id/tabcontent" 
        android:layout_width="0dp" 
        android:layout_height="0dp" /> 

       <android.support.v4.view.ViewPager 
        android:id="@+id/viewpager" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" /> 
      </FrameLayout> 

       <TabWidget 
        android:id="@android:id/tabs" 
        android:layout_width="fill_parent" 
        android:layout_height="wrap_content" 
        android:dividerPadding="0dp" 
        android:showDividers="none" 
        android:tabStripEnabled="false" 
        android:layout_gravity="top" /> 
     </FrameLayout> 

</TabHost> 
관련 문제