0
我想在應用程序的操作欄(標題,應用程序圖片等欄)下面有一個「信息欄/文本視圖」。你可以添加一個文本視圖到一個操作欄嗎?如果沒有,一個子操作欄?
我在我的應用程序上有選項卡,我想要信息對象在操作欄下方的標籤上方。我知道如何使用佈局將主佈局xml更改爲標籤下方,但我無法弄清楚是否可以將標籤放在標籤上方。我無法將它放在標籤上方,因爲我認爲它們是操作欄的「一部分」。
我想在應用程序的操作欄(標題,應用程序圖片等欄)下面有一個「信息欄/文本視圖」。你可以添加一個文本視圖到一個操作欄嗎?如果沒有,一個子操作欄?
我在我的應用程序上有選項卡,我想要信息對象在操作欄下方的標籤上方。我知道如何使用佈局將主佈局xml更改爲標籤下方,但我無法弄清楚是否可以將標籤放在標籤上方。我無法將它放在標籤上方,因爲我認爲它們是操作欄的「一部分」。
爲信息欄和選項卡創建xml佈局。例如:
<?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」?這將是標籤佔用的空間。按照示例here。從示例獲取的鏈接:
/* 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。
hmm。我一直想知道同樣的事情。即時通訊在新功能方面並不那麼知識淵博 – user1147223 2013-04-30 03:15:49