淘小米 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"
        />
    
    评论

报告相同问题?

悬赏问题

  • ¥15 用matlab 设计一个不动点迭代法求解非线性方程组的代码
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试
  • ¥20 问题请教!vue项目关于Nginx配置nonce安全策略的问题
  • ¥15 教务系统账号被盗号如何追溯设备
  • ¥20 delta降尺度方法,未来数据怎么降尺度
  • ¥15 c# 使用NPOI快速将datatable数据导入excel中指定sheet,要求快速高效