你可以添加一个TextView一个动作吧?如果不是这样,一个子动作条? [英] Can you add a textview to an action bar? If not, a sub actionbar?

查看:130
本文介绍了你可以添加一个TextView一个动作吧?如果不是这样,一个子动作条?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想有一个信息栏/ TextView的右下面我的应用程序的操作栏(栏写着标题,应用程序的图片,等等)。

I wanted to have a "info bar/textview" right below my App's action bar (the bar that says the title, app picture, etc).

我有我的应用程序选项卡,和我想要的信息栏上方的标签,右下方的操​​作栏。我知道如何更改主的布局XML来把它使用布局选项卡下面,但我不能弄清楚是否有可能把标签上方的酒吧。我不能把它的标签上面,因为我觉得他们的操作栏的部分。

I have tabs on my application, and I wanted the infobar ABOVE the tabs, right below the action bar. I know how to change the main' layout xml to put it below the tabs using a layout, but I can't figure out if it's possible to place the bar above the tabs. I can't put it above the tabs because I think they're 'part' of the action bar.

推荐答案

创建信息栏和标签的XML布局。例如:

Create the xml layout for the infobar and the tabs. For example:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <TextView
        android:id="@+id/infobar"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Info Bar" />

    <RelativeLayout
        android:id="@id/tab_layout"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_below="@+id/infobar" >
    </RelativeLayout>

</RelativeLayout>

替换TextView的信息栏有自己的布局。请注意,相对布局tab_layout?这将是将由片所占据的空间。按照例如 rel="nofollow">。从这个例子所采取的链接:

Replace the infobar textview with your own layout. Notice the relative layout "tab_layout"? That will be the space that will be occupied by the tabs. Follow the example here. Taken from the example on the link:

/* The following are each of the ActionBar.TabListener callbacks */

    public void onTabSelected(Tab tab, FragmentTransaction ft) {
        // Check if the fragment is already initialized
        if (mFragment == null) {
            // If not, instantiate and add it to the activity
            mFragment = Fragment.instantiate(mActivity, mClass.getName());
            ft.add(android.R.id.content, mFragment, mTag);
        } else {
            // If it exists, simply attach it in order to show it
            ft.attach(mFragment);
        }
    }

更改此: ft.add(android.R.id.content,mFragment,MTAG)这个 ft.add(R.id .tab_layout,mFragment,MTAG)。请注意,我们用我们自己的布局,而不是android.R.id.content。

Change this: ft.add(android.R.id.content, mFragment, mTag) to this ft.add(R.id.tab_layout, mFragment, mTag). Notice that we used our own layout instead of android.R.id.content.

这篇关于你可以添加一个TextView一个动作吧?如果不是这样,一个子动作条?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆