當前位置:首頁 » 安卓系統 » android標題欄

android標題欄

發布時間: 2022-01-10 16:11:18

Ⅰ 關於Android中標題欄上的這個菜單

這個可以用官方的FloatingActionButton做出來,需要Demo的話請追問。

Ⅱ android的Activity控制項標題欄的屬性怎麼設置啊

Activity的標題欄,叫ActionBar,ActionBar位於Activity的頂部,可用來顯示activity的標題、Icon、Actions和一些用於交互的View。它也可被用於應用的導航。


ActionBar 標題欄常用屬性:

  1. showAsAction屬性用來定義每個Action是如何顯示的

  2. always表示永遠顯示在ActionBar中,如果屏幕空間不夠則無法顯示

  3. ifRoom表示屏幕空間夠的情況下顯示在ActionBar中,不夠的話就顯示在overflow中

  4. never則表示永遠顯示在overflow中

Ⅲ android 怎麼設置標題欄大小

安卓app中的內置標題欄不同版本差異很大,但無論是2.3以下或4.0以上系統的標題欄,能自定義的屬性都很少。在開發Android應用中,想創建一個漂亮的自定義標題欄,有兩種方法,
第一,使用第三方框架,如SerlockActionbar。
第二,在XML中頭部做一個layout來作為標題欄(實際上就是普通的view)
我使用的是第二種方法,靈活性強些。

Ⅳ android標題欄高度是多少

1、獲取標題欄高度: getWindow().findViewById(Window.ID_ANDROID_CONTENT)這個方法獲取到的view就是程序不包括標題欄的部分,然後就可以知道標題欄的高度了。

1
2
3

int contentTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
//statusBarHeight是上面所求的狀態欄的高度
int titleBarHeight = contentTop - statusBarHeight

擴展:
1、獲取狀態欄高度:
decorView是window中的最頂層view,可以從window中獲取到decorView,然後decorView有個getWindowVisibleDisplayFrame方法可以獲取到程序顯示的區域,包括標題欄,但不包括狀態欄。於是,我們就可以算出狀態欄的高度了。

1
2
3

Rect frame = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;

2、獲取屏幕高度

1
2
3
4
5

方法1:
WindowManager windowManager = getWindowManager();
Display display = windowManager.getDefaultDisplay();
screenWidth = display.getWidth();
screenHeight = display.getHeight();

1
2
3
4
5

方法2:
DisplayMetrics dm = new DisplayMetrics();
this.getWindowManager().getDefaultDisplay().getMetrics(dm);//this指當前activity
screenWidth =dm.widthPixels;
screenHeight =dm.heightPixels;

Ⅳ android如何去掉標題欄

在android中去掉標題欄有三種方法,它們也有各自的特點。

1.在代碼里實現

[java]view plain

this.requestWindowFeature(Window.FEATURE_NO_TITLE);//去掉標題欄

記住:這句代碼要寫在setContentView()前面。


2.在清單文件(manifest.xml)裡面實現


[java]view plain

<applicationandroid:icon="@drawable/icon"

android:label="@string/app_name"

android:theme="@android:style/Theme.NoTitleBar">

這樣用可以將整個應用設置成無標題欄,如果只需要在一個Activity設置成一個無標題欄的形式,只要把上面的第三行代碼寫到某一個Activity裡面就可以了。


3.在style.xml文件里定義


[html]view plain

<?xmlversion="1.0"encoding="UTF-8"?>

<resources>

<stylename="notitle">

<itemname="android:windowNoTitle">true</item>

</style>

</resources>

然後面manifest.xml中引用就可以了,這種方法稍麻煩了些。



[html]view plain

<applicationandroid:icon="@drawable/icon"

android:label="@string/app_name"

android:theme="@style/notitle">



其實可以看得出來,第二種方法和第三種方法實質是一樣的,只不過第二種方法調用的是系統定義好的style.xml文件,而第三種方法則是在自己的應用里定義style.xml,然後再自己再調用,其實道理是一樣的,第三種方法做起來更有成就感。


Ⅵ 如何修改android標題欄界面

方法一、在你的那張Activity中onCreate方法中加上下面代碼:

?

requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
setContentView(R.layout.main); //軟體activity的布局
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.titlebar); //titlebar為自己標題欄的布局

但是新的問題又來了,這樣是無法深層的定製標題欄的,比如原有的高度和背景都沒有發生變化,那有沒有好的方法呢?答案是有的、
方法二:
因此先定義一個style,若修改背景請修改android:windowTitleBackgroundStyle
若修改標題欄高度,請修改android:windowTitleSize
例子:

?

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="schemas.android.com/apk/res/android">

<style name="CustomWindowTitleBackground">
<item name="android:background">#565656</item>
</style>

<style name="test" parent="android:Theme">
<item name="android:windowTitleSize">50dp</item>
<item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
</style>
</resources>

在程序的android_manifest.xml中對應activity中添加屬性android:theme = "@style/test" 就可以了
?

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="schemas.android.com/apk/res/android"
package="com.guardian"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name" >
<activity android:name=".Test"
android:label="@string/app_name"
android:theme = "@style/test" //就在這里
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

</application>
<uses-sdk android:minSdkVersion="4" />

</manifest>

Ⅶ android怎麼不顯示標題欄

你的活動估計是按照教材上繼承的Activity,但你打開你主題的styles.xml,很可能會發現<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
設定中用到了AppCompat的主題解決辦法就是讓所有的活動都繼承 AppCompatActivity就行了,如下:public class 你的活動 extends AppCompatActivity

Ⅷ 怎麼在android的標題欄上面加控制項

Android 標題欄添加控制項及Button控制項背景顏色的設置
一、Android中標題欄添加按
現在很多的Android程序都在標題欄上都顯示了一些按鈕和標題,如下圖:

下面通過實例來看一下如何實現。
1、 在layout下創建一個titlebtn.xml文件,內容如下: <?xml version="1.0" encoding="utf-8"?>
<RelativeLayoutxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="horizontal">
<ImageButton
android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_centerVertical="true" android:background="#00000000" android:src="@drawable/prv"/>
<TextView
android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true" android:text="標題欄"/>
<ImageButton
android:id="@+id/imageButton1" android:layout_width="wrap_content" android:layout_height="wrap_content"

android:layout_alignParentRight="true" android:layout_centerInParent="true" android:background="#00000000" android:src="@drawable/next"/>

</RelativeLayout>
在創建這個xml時需要注意: a)使用RelativeLayout的布局
b)特別是右邊按鈕的屬性需要指定layout_centerInParent

Ⅸ android的Activity控制項標題欄的屬性怎麼設置啊

Activity的標題欄,叫ActionBar,ActionBar位於Activity的頂部,可用來顯示activity的標題、Icon、Actions和一些用於交互的View。它也可被用於應用的導航。
ActionBar
標題欄常用屬性:
showAsAction屬性用來定義每個Action是如何顯示的
always表示永遠顯示在ActionBar中,如果屏幕空間不夠則無法顯示
ifRoom表示屏幕空間夠的情況下顯示在ActionBar中,不夠的話就顯示在overflow中
never則表示永遠顯示在overflow中

Ⅹ android開發中如何自定義標題欄

manifest文件中定義無標題欄的主題,然後自己用TextView做個標題欄。

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:760
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:659
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:306
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:284
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:812
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:158
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:89
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:503
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:655
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:479