zoukankan      html  css  js  c++  java
  • LinearLayout、RelativeLayout、FrameLayout居中显示

    LinearLayout、RelativeLayout、FrameLayout居中显示需要设置的属性不一样,今天总结下,方便以后使用~~

    布局文件如下:

    <?xml version="1.0" encoding="utf-8"?> 
     <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
         android:orientation="vertical" 
         android:layout_width="fill_parent" 
         android:layout_height="fill_parent" 
         > 
         <LinearLayout  
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content" 
             android:gravity="center_horizontal" 
             android:orientation="vertical"> 
             <ImageView  
                 android:layout_width="wrap_content" 
                 android:layout_height="wrap_content" 
                 android:background="@drawable/icon" 
                 /> 
         </LinearLayout> 
         <FrameLayout  
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"> 
             <ImageView  
                 android:layout_width="wrap_content" 
                 android:layout_height="wrap_content" 
                 android:background="@drawable/icon" 
                 android:layout_gravity="center" 
                 /> 
         </FrameLayout> 
         <RelativeLayout  
             android:layout_width="fill_parent" 
             android:layout_height="wrap_content"> 
             <ImageView  
                 android:layout_width="wrap_content" 
                 android:layout_height="wrap_content" 
                 android:background="@drawable/icon" 
                 android:layout_centerInParent="true" 
                 /> 
         </RelativeLayout> 
     </LinearLayout> 
     效果如下:
     

    转自 http://www.2cto.com/kf/201201/116391.html

    Crazy Cherry:everything is possible!
  • 相关阅读:
    数据结构_队列和滑动窗口
    数据结构_栈和单调栈
    数据结构_链表及邻接表
    JavaSE多线程
    AppExtension总结
    FlutterBloc 2.1.1迁移至6.0.6
    iOS通知总结
    Provider 4.3.2+2 f
    Fish-Redux 研究
    王道考研复习-操作系统-内存管理(三)
  • 原文地址:https://www.cnblogs.com/userbibi/p/2469489.html
Copyright © 2011-2022 走看看