문제

FragmentActivity 레이아웃에서 FragmentTabhost가 있습니다.

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@+id/llDetector"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >

        <FrameLayout
            android:id="@+id/realtabcontent"
            android:layout_width="match_parent"
            android:layout_height="0dip"
            android:layout_weight="1" />

        <android.support.v4.app.FragmentTabHost
            android:id="@android:id/tabhost"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >
    <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="0dp"
                android:layout_height="0dp"
                android:layout_weight="0" />
        </android.support.v4.app.FragmentTabHost>

    </LinearLayout>
.

여기에 이미지 설명

그것은 잘 작동하지만, TabStrip이 tabwidget의 맨 위에 있기를 원합니다.어떻게 그것을 성취 할 수 있습니까?미리 감사드립니다!

도움이 되었습니까?

해결책

괜찮아, 나는 그것을했다.

내가 한 일은 내 tabwidget의 레이아웃을 팽창시키고 내 fragmenttabhost에 추가하는 것입니다.

다음과 같이 :

View vTab = LayoutInflater.from(this).inflate(R.layout.tab_icon,    null, false);
mainTabhost.addTab(mainTabhost.newTabSpec("tab1").setIndicator(vTab),   Fragment_Sample.class, null);
.

및 내 TAB_ICON XML 파일 :

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="vertical" >

    <TextView
        android:layout_width="match_parent"
        android:layout_height="3dp"
        android:background="@drawable/tab_icon_selector_inverse"
        android:textColor="@color/white" />

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:background="@drawable/tab_icon_selector"
        android:drawableTop="@drawable/ic_icons"
        android:gravity="center"
        android:paddingBottom="5dp"
        android:paddingTop="5dp"
        android:text="@string/static_tab_whats_up"
        android:textColor="@color/white"
        android:textSize="11sp" />

</LinearLayout>
.

어떤 경우에도이를 필요로합니다.이것은 도움이 될 것입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top