首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >带有重叠徽标的android自定义标题栏

带有重叠徽标的android自定义标题栏
EN

Stack Overflow用户
提问于 2013-01-31 15:43:38
回答 2查看 428关注 0票数 1

我希望在我的Android应用程序中有这样的自定义标题栏:

  • 自定义标题栏
  • 有两个标准按钮,一个左对齐(A)和一个右对齐(C)
  • 中间可点击的标志(B)
  • 此徽标超出标题栏并与内容重叠。

当点击(A)或(C)时,它将启动一项活动。当点击(B)时,它会显示一个小菜单,最终开始其他活动。

你知道如何在Android中实现这一点吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-01-31 16:40:25

试试这个,我正在使用Relative layoutFramelayout

代码语言:javascript
复制
 <?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="fill_parent"
  android:orientation="vertical" >

<RelativeLayout
    android:id="@+id/parent_linear"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:text="Button1" />

    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:text="Button2" />
</RelativeLayout>

<RelativeLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_below="@id/parent_linear" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry&apos;s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book" />
</RelativeLayout>

<FrameLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true" >

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="80dip"
        android:background="@drawable/ic_launcher" />
</FrameLayout>

票数 0
EN

Stack Overflow用户

发布于 2013-01-31 15:50:29

我不知道您是否可以在ActionBar中直接这样做,但是您可以使用RelativeLayout并将该条绑定到顶部。

有点像

代码语言:javascript
复制
<?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="fill_parent" >

    <RelativeLayout
        android:id="@+id/myBar"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:layout_alignParentTop="true"
        android:orientation="vertical" >

        <-- All the stuff to design the bar -->

    </RelativeLayout>

</RelativeLayout>

此外,您还可以删除标准标题栏并使用无标题主题。

代码语言:javascript
复制
<activity android:theme="@android:style/Theme.Black.NoTitleBar">

PS:画得不错。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14629545

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档