重新创建 Google+ / Google Reader 喜欢标题导航栏??? (安卓)

发布于 2024-12-05 10:32:50 字数 2005 浏览 3 评论 0原文

我为我正在开发的应用程序创建了一个与下面的屏幕截图非常相似的标题菜单。但是,我不太清楚如何使按钮始终保持与右侧齐平,并且徽标所在的字段自动填充剩余的屏幕空间(即屏幕旋转后)。

屏幕截图 I | 屏幕截图 II

我确信解决方案有一些内容与layout_width属性有关,但我不知道如何 确切地。任何帮助将不胜感激!他们目前处于相对布局中...

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

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

女皇必胜 2024-12-12 10:32:50

@+id/logo 上尝试添加 android:layout_weight="1"

您还需要从 RelativeLayout 更改为 >线性布局

请参阅http://android-developers.blogspot.com/ 2009/02/android-layout-tricks-1.html

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文