淘小米 2013-09-18 02:52 采纳率: 50%
浏览 3057

android界面标签无法居中

本人菜鸟,刚刚开始学着写第一个android app 遇到一个也许是很菜的问题,但是被纠结了一天都没搞出来,麻烦大神指点下。
我的目的是想让home 和favorite 两个按钮居中,play按钮靠右,但是试了好多办法都调不到我想要的位置上。
界面截图:
CSDN移动问答

代码如下:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:layout_gravity="center_vertical"
android:orientation="vertical" >

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="fill_horizontal"
    android:background="@drawable/nav_bar_background_img_2x"
    android:orientation="horizontal" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center_horizontal|center_vertical"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/home"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:background="@drawable/nav_main_selected_2x" />

    <Button
        android:id="@+id/favorite"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:background="@drawable/nav_favorite_2x" />
</LinearLayout>

<Button
    android:id="@+id/playlist"
    android:layout_width="48dp"
    android:layout_height="48dp"
    android:layout_gravity="right"
    android:layout_marginRight="5dp"
    android:background="@drawable/popview_playbtn_2x" />

</LinearLayout>

<com.org.happyenglish.service.list.ItemListView
    android:id="@+id/list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    />

  • 写回答

3条回答 默认 最新

  • Jobernowl 2013-09-18 03:59
    关注
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/background"
    android:layout_gravity="center_vertical"
    android:orientation="vertical" >
    
    <FrameLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_gravity="fill_horizontal"
        android:background="@drawable/nav_bar_background_img_2x" >
    
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal|center_vertical"
        android:orientation="horizontal" >
    
        <Button
            android:id="@+id/home"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:background="@drawable/nav_main_selected_2x" />
    
        <Button
            android:id="@+id/favorite"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@drawable/nav_favorite_2x" />
    </LinearLayout>
    
    <Button
        android:id="@+id/playlist"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:layout_gravity="right"
        android:layout_marginRight="5dp"
        android:background="@drawable/popview_playbtn_2x" />
    
    </FrameLayout>
    
    <com.org.happyenglish.service.list.ItemListView
        android:id="@+id/list"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        />
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度