Android初学习 - LinearLayout、RelativeLayout、FrameLayout内容居中显示

XML如下:

  1. xml version="1.0" encoding="utf-8"?>   
  2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"   
  3.     android:orientation="vertical"   
  4.     android:layout_width="fill_parent"   
  5.     android:layout_height="fill_parent"   
  6.     >   
  7.     <LinearLayout    
  8.         android:layout_width="fill_parent"   
  9.         android:layout_height="wrap_content"   
  10.         android:gravity="center_horizontal"   
  11.         android:orientation="vertical">   
  12.         <ImageView    
  13.             android:layout_width="wrap_content"   
  14.             android:layout_height="wrap_content"   
  15.             android:background="@drawable/icon"   
  16.             />   
  17.     LinearLayout>   
  18.     <FrameLayout    
  19.         android:layout_width="fill_parent"   
  20.         android:layout_height="wrap_content">   
  21.         <ImageView    
  22.             android:layout_width="wrap_content"   
  23.             android:layout_height="wrap_content"   
  24.             android:background="@drawable/icon"   
  25.             android:layout_gravity="center"   
  26.             />   
  27.     FrameLayout>   
  28.     <RelativeLayout    
  29.         android:layout_width="fill_parent"   
  30.         android:layout_height="wrap_content">   
  31.         <ImageView    
  32.             android:layout_width="wrap_content"   
  33.             android:layout_height="wrap_content"   
  34.             android:background="@drawable/icon"   
  35.             android:layout_centerInParent="true"   
  36.             />   
  37.     RelativeLayout>   
  38. LinearLayout>   

你可能感兴趣的:(Android)