gpt4 book ai didi

java - 如何在 TabWidget 上方添加 ActionBar?

转载 作者:行者123 更新时间:2023-12-02 08:18:38 24 4
gpt4 key购买 nike

我正在 TabHost 上方创建一个自定义栏。由于某种原因,自定义栏不会出现在 TabHost 上方,而是绘制在其后面。不知道为什么。这是我的 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>

最佳答案

请勿使用 TabHost 作为布局的根。将您的 TabHost 放入具有 orientation:verticalLinearLayout 中。

然后在 LinearLayout 内、TabHost 之前,您可以放置​​ ActionBar。

关于java - 如何在 TabWidget 上方添加 ActionBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5876547/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com