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

当点击(A)或(C)时,它将启动一项活动。当点击(B)时,它会显示一个小菜单,最终开始其他活动。
你知道如何在Android中实现这一点吗?
发布于 2013-01-31 16:40:25
试试这个,我正在使用Relative layout和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'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-31 15:50:29
我不知道您是否可以在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:画得不错。
https://stackoverflow.com/questions/14629545
复制相似问题