Comment ajouter une ActionBar au-dessus d'un TabWidget?
-
28-10-2019 - |
Question
Je crée une barre personnalisée au-dessus d'un TabHost.Pour une raison quelconque, la barre personnalisée n'apparaît pas au-dessus de TabHost, mais elle est dessinée derrière lui.Pas certain de pourquoi.Voici mon XML:
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@android:id/tabhost"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<!--
<RelativeLayout android:layout_height="wrap_content" android:layout_width="match_parent" android:id="@+id/actionbarRelativeLayout">
<ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/stocktwitsImageButton"></ImageButton>
<ImageButton android:layout_height="wrap_content" android:layout_width="wrap_content" android:src="@drawable/icon" android:id="@+id/composeImageButton" android:layout_alignParentRight="true"></ImageButton>
</RelativeLayout>
-->
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp">
<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="fill_parent"
android:layout_height="fill_parent"
android:padding="5dp" />
</LinearLayout>
</TabHost>
La solution
N'utilisez pas TabHost
comme racine de votre mise en page.Mettez votre TabHost
dans un LinearLayout
avec orientation:vertical
.
Ensuite, dans le LinearLayout
et avant le TabHost
, vous pouvez mettre votre ActionBar.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow