展会信息港展会大全

LinearLayout、RelativeLayout、FrameLayout居中显示
来源:互联网   发布日期:2015-10-14 07:48:16   浏览:1637次  

导读:LinearLayout、RelativeLayout、FrameLayout居中显示需要设置的属性不一样,今天总结下,方便以后使用~~布局文件如下:<?xml version="1.0...

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>

效果如下:\

摘自 xiaoxiaobian3310903的专栏

赞助本站

人工智能实验室

相关热词: android开发 教程

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港