mono for android 自定義titleBar Actionbar 頂部導航欄 修改 樣式 學習


 以前的我是沒有做筆記的習慣的,學習了后覺得自己能記住,但是最近發現很多學的東西都忘記了,所有現在一有新的知識,就記下來吧。

 最近又做一個mono for android 的項目 這次調整比較大,上次做的點餐系統很好用 ,但是做的時候沒有做筆記很多東西都忘記了,這次我把項目涉及到的知識傳到博客上,方便記憶,也很大家分享分享的,希望大家能給出點意見。

 

在value里面新建 mystyle.xml

<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://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">40dp</item>
    <item name="android:windowTitleBackgroundStyle">@style/CustomWindowTitleBackground</item>
  </style>
</resources>

在Layout里面新建布局myTitle.axml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="#f5f5f5"
              >
  <LinearLayout
      android:id="@+id/mytitlebar"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="horizontal"
      >
    <ImageView
         android:id="@+id/logo"
         android:layout_width="wrap_content"
         android:layout_height="wrap_content"
         android:src="@drawable/Logo"
        />
    <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="彩雲"
      android:textSize="32sp"
        />
  </LinearLayout>
</LinearLayout>

在activity中先加入樣式 Theme = "@style/test"
[Activity(Label = "Cloud", MainLauncher = true, Icon = "@drawable/icon", Theme = "@style/test")]

 

再替換掉原有的titleBar

 

 // 設置我自己的titleBar
            //聲明使用自己的的ActionBar 
            this.RequestWindowFeature(WindowFeatures.CustomTitle);

    //設置布局  !注意順序
            SetContentView(Resource.Layout.Main);
            //設置titleBae
            SetTitle(Resource.Layout.myTitle);
            Window.SetFeatureInt(WindowFeatures.CustomTitle, Resource.Layout.myTitle);

 

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM