我是靠谱客的博主 大胆大米,这篇文章主要介绍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>  
效果如下:


最后

以上就是大胆大米最近收集整理的关于LinearLayout、RelativeLayout、FrameLayout居中显示的全部内容,更多相关LinearLayout、RelativeLayout、FrameLayout居中显示内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(120)

评论列表共有 0 条评论

立即
投稿
返回
顶部