如何创建Android自定义标题栏

如何创建Android自定义标题栏,android,customization,titlebar,Android,Customization,Titlebar,我尝试在Android上构建一个应用程序。 我是Android新手。 但我不知道如何建立这样的标题栏。 因此,我们可以通过tab按钮提供应用程序名称,如Seesmic和Komutta。 有谁能帮我给出答案,或者仅仅是那个教程的链接 <item android:top="20dp"> <shape android:shape="rectangle"> <gradient android:angle="90" android:endcolor="

我尝试在Android上构建一个应用程序。 我是Android新手。 但我不知道如何建立这样的标题栏。 因此,我们可以通过tab按钮提供应用程序名称,如Seesmic和Komutta。 有谁能帮我给出答案,或者仅仅是那个教程的链接

<item android:top="20dp">
    <shape android:shape="rectangle">
        <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
    </gradient></shape>
</item>
多谢各位

<item android:top="20dp">
    <shape android:shape="rectangle">
        <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
    </gradient></shape>
</item>

<item android:top="20dp">
    <shape android:shape="rectangle">
        <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
    </gradient></shape>
</item>

<item android:top="20dp">
    <shape android:shape="rectangle">
        <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
    </gradient></shape>
</item>

很抱歉,我无法上传该图像,所以我只能提供该图像的链接。

这称为“操作栏”,您可以从本机开始获取,或者在早期版本的android上获取代码,android站点有一个可以查看的演示,并且

<item android:top="20dp">
    <shape android:shape="rectangle">
        <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
    </gradient></shape>
</item>
  • 创建一个新项目并将您的主要活动命名为“MyActivity”
  • 转到res-drawable并创建一个新的xml文件,将其称为“custom_title_background”,并输入以下代码:

    <item android:top="20dp">
        <shape android:shape="rectangle">
            <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
        </gradient></shape>
    </item>
    
    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:textSize="16sp"
              android:textColor="@android:color/white"
              android:textStyle="bold"
              android:id="@+id/custom_title_text"
              android:layout_centerInParent="true"
              android:shadowColor="@android:color/black"
              android:shadowRadius="3"/>
    

    <item android:top="20dp">
        <shape android:shape="rectangle">
            <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
        </gradient></shape>
    </item>
    
    }

  • <item android:top="20dp">
        <shape android:shape="rectangle">
            <gradient android:angle="90" android:endcolor="#9eacbf" android:startcolor="#8296af">
        </gradient></shape>
    </item>
    

    谢谢你的建议,但它仍然出现在我的应用程序第一次启动时的标题,但时间不长。我们怎样才能解决这个问题?