1

我想在我的 Android 应用程序中使用这种自定义标题栏:

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

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

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

4

2 回答 2

0

我不知道您是否可以直接在 ActionBar 中执行此操作,但您可以使用 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="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>

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

<activity android:theme="@android:style/Theme.Black.NoTitleBar">

PS:画的不错。

于 2013-01-31T15:50:29.237 回答
0

试试这个,我正在使用Relative layoutand Framelayout

在此处输入图像描述

 <?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>

于 2013-01-31T16:40:25.437 回答