开发者

Recreate Google+ / Google Reader Like Header Nav Bar??? (Android)

I've created a header menu that is very similar to the screen shots below for an app that I'm working on. However, I can't quite figure out how to make the buttons always stay flush to the right and the field that the logo is in auto-fill the remaining screen space (ie after a screen rotation).

Screenshot I | Screenshot II

I'm sure the solution has something to do 开发者_运维问答with the the layout_width attribute but I can't figure out how exactly. Any help will be greatly appreciated!!! They are currently in a RelativeLayout...

<RelativeLayout android:layout_width="fill_parent"
    android:layout_height="50sp"
    android:background="@color/red"
    android:padding="0px">

    <TextView android:id="@+id/logo" 
        android:layout_width="200sp" 
        android:layout_height="50sp"
        android:text="Logo" android:gravity="center_vertical"/>

    <TextView android:id="@+id/dividerOne" 
        android:layout_width="1px" 
        android:layout_height="50sp" 
        android:layout_toRightOf="@+id/logo"
        android:layout_alignTop="@id/logo"
        android:background="@color/white"
        android:text="" />

    <TextView android:id="@+id/blockList" 
        android:layout_width="50sp" 
        android:layout_height="50sp"
        android:layout_toRightOf="@+id/dividerOne"
        android:layout_alignTop="@id/dividerOne"
        android:gravity="center"
        android:text="Block List" />

    <TextView android:id="@+id/dividerTwo" 
        android:layout_width="1px" 
        android:layout_height="50sp" 
        android:layout_toRightOf="@+id/blockList"
        android:layout_alignTop="@id/blockList"
        android:background="@color/white"
        android:text="" />

    <TextView android:id="@+id/Log" 
        android:layout_width="50sp" 
        android:layout_height="50sp"
        android:layout_toRightOf="@+id/dividerTwo"
        android:layout_alignTop="@id/dividerTwo"
        android:gravity="center"
        android:text="Log"/>

</RelativeLayout>


On @+id/logo try adding android:layout_weight="1"

You'll also need to change from a RelativeLayout to a LinearLayout.

See http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜