淘小米 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 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题