当前位置: 代码迷 >> Android >> 安卓布局有关问题
  详细解决方案

安卓布局有关问题

热度:92   发布时间:2016-04-28 06:53:46.0
安卓布局问题

<!-- 中间图标 -->
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="match_parent"
        android:gravity="center|center_vertical" 
        android:orientation="vertical">

        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/butn_shake_ico"
            android:background="@drawable/butn_shake_home_p" />
        
    </LinearLayout>
<!-- 结束中间图标 -->

    <!-- 底部菜单 -->

    <RelativeLayout
        android:id="@+id/main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >
    
        <LinearLayout android:id="@+id/bottom_panel" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:orientation="horizontal" 
            android:layout_alignParentBottom="true" > 
            
            <include layout="@layout/menu"/>        
        </LinearLayout> 
        
</RelativeLayout> 
    <!-- 结束底部菜单 -->


我想问如何才能让中间的那个图标放在垂直居中的位置?
------解决方案--------------------
整体是个 LinearLayout,中间当然要用一个 RelativeLayout 套一层了。
------解决方案--------------------
有几点没搞懂你的意思
中间的LinearLayout和底部的RelativeLayout的外层的容器是什么,然后你把<RelativeLayout
        android:id="@+id/main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" >是什么意思,底部menu干嘛要填充全部?

下面是我根据我的理解写的
<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
   
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    >
    
    
    
    <!-- 中间图标 -->
   
 
        <ImageView
            android:id="@+id/imageView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/ic_launcher"
            android:layout_centerInParent="true"
            />
         
   
<!-- 结束中间图标 -->
 
    <!-- 底部菜单 -->
 
    
     
        <LinearLayout android:id="@+id/bottom_panel" 
            android:layout_width="fill_parent" 
            android:layout_height="wrap_content" 
            android:orientation="horizontal" 
            android:layout_alignParentBottom="true" > 
             
            <include layout="@layout/umeng_socialize_actionbar"/>        
        </LinearLayout> 
         
  相关解决方案