Android自定义Title

自定义TitleBar

点击(此处)折叠或打开

  1. super.onCreate(savedInstanceState);

  2.         requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);

  3.         setContentView(R.layout.activity_main);

  4.         getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.title);

title.xml www.huaqiangu6.com

点击(此处)折叠或打开

  1. <?xml version="1.0" encoding="utf-8"?>

  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"

  3.     android:layout_width="fill_parent"

  4.     android:layout_height="wrap_content"

  5.     android:orientation="horizontal" >


  6.     <ImageView

  7.         android:layout_width="wrap_content"

  8.         android:layout_height="wrap_content"

  9.         android:gravity="bottom"

  10.         android:src="@drawable/ic_launcher" />


  11.     <TextView

  12.         android:layout_width="wrap_content"

  13.         android:layout_height="38dip"

  14.         android:paddingTop="1dip"

  15.         android:text="@string/app_name"

  16.         android:textColor="#FFFFFFFF"

  17.         android:textSize="14dip" />


  18.     <EditText

  19.         android:id="@+id/searchparameter"

  20.         android:layout_width="wrap_content"

  21.         android:layout_height="38dip"

  22.         android:layout_margin="1dip"

  23.         android:text="ABCDEFGHIJ"

  24.         android:textSize="14dip" />


  25.     <Button

  26.         android:id="@+id/button"

  27.         android:layout_width="wrap_content"

  28.         android:layout_height="38dip"

  29.         android:text="OK"

  30.         android:textSize="14dip" />


  31. </LinearLayout>


title大小:

点击(此处)折叠或打开

  1. <application

  2.         android:allowBackup="true"

  3.         android:icon="@drawable/icon_main_menu"

  4.         android:theme="@style/AppTheme"

  5.          >

AppTheme

点击(此处)折叠或打开

  1. <!-- Application theme. -->

  2.     <style name="AppTheme" parent="android:Theme">

  3.          <item name="android:windowTitleSize">40dp</item> 

  4.     </style>



你可能感兴趣的:(android)