当前位置:操作系统 > 安卓/Android >>

百度应用 android客户端(一)自定义导航栏

title布局activity_main_title.xml

 

 

[html] 
<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:background="@color/title_background" 
    android:orientation="vertical" > 
 
    <ImageView 
        android:id="@+id/icon" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:src="@drawable/icon" /> 
    <TextView  
        android:id="@+id/icon_text" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/title_name" 
        android:layout_toRightOf="@id/icon" 
        android:textSize="18sp"/> 
    
     
    <ImageView 
        android:id="@+id/applist" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentRight="true" 
        android:onClick="show_applist" 
        android:src="@drawable/titlebar_applist_normal" /> 
     
     <ImageView 
        android:id="@+id/searchbt" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_toLeftOf="@id/applist" 
        android:onClick="search_app" 
        android:src="@drawable/titlebar_search_normal" /> 
 
</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="match_parent"
    android:background="@color/title_background"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/icon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:src="@drawable/icon" />
 <TextView www.zzzyk.com
     android:id="@+id/icon_text"
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:text="@string/title_name"
     android:layout_toRightOf="@id/icon"
     android:textSize="18sp"/>
  
   
    <ImageView
        android:id="@+id/applist"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
   android:layout_alignParentRight="true"
   android:onClick="show_applist"
        android:src="@drawable/titlebar_applist_normal" />
   
     <ImageView
        android:id="@+id/searchbt"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toLeftOf="@id/applist"
        android:onClick="search_app"
        android:src="@drawable/titlebar_search_normal" />

</RelativeLayout>


 

 

关键代码:

 


\

 \

[java] 
requestWindowFeature(Window.FEATURE_CUSTOM_TITLE); 
setContentView(R.layout.activity_main); 
getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_main_title); 

        requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
        setContentView(R.layout.activity_main);
        getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_main_title);
  

               其中

 
 view plaincopyprint?
<resources>     
    <style name="StatusBarBackground"> 
        <item name="android:background">@drawable/shape</item> 
    </style> 
             
    <style name="XWindowTitle" <SPAN style="COLOR: #ff0000">parent="android:WindowTitle"> 
</SPAN>        <item name="android:shadowColor">#BB000000</item> 
        <item name="android:shadowRadius">0</item> 
    </style> 
</resources> 

<resources>   
    <style name="StatusBarBackground">
      &n

补充:移动开发 , Android ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,