重新创建 Google+ / Google Reader 喜欢标题导航栏??? (安卓)
我为我正在开发的应用程序创建了一个与下面的屏幕截图非常相似的标题菜单。但是,我不太清楚如何使按钮始终保持与右侧齐平,并且徽标所在的字段自动填充剩余的屏幕空间(即屏幕旋转后)。
我确信解决方案有一些内容与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).
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(1)
在
@+id/logo
上尝试添加android:layout_weight="1"
您还需要从
RelativeLayout
更改为>线性布局
。请参阅http://android-developers.blogspot.com/ 2009/02/android-layout-tricks-1.html
On
@+id/logo
try addingandroid:layout_weight="1"
You'll also need to change from a
RelativeLayout
to aLinearLayout
.See http://android-developers.blogspot.com/2009/02/android-layout-tricks-1.html