网络111 徐京浩

 

 

第一部是往drawable文件夹里放一个图片名为icon.png的图片,首先在这里说明Android只能放扩展名为png、jpg、gif的图片;

 

然后编写main.xml文件,代码如下:

 

 

<?xml version="1.0" encoding="utf-8"?> 

    android:layout_width="match_parent" 

    android:layout_height="match_parent" > 

   

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" 

        android:background="@drawable/icon" 

        android:layout_centerInParent="true" 

        android:id="@+id/image0"/> 

   

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" 

        android:background="@drawable/icon" 

        android:layout_above="@id/image0" 

        android:layout_toLeftOf="@id/image0" 

        android:id="@+id/image1"/> 

   

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" 

        android:background="@drawable/icon" 

        android:layout_above="@id/image0" 

        android:layout_toRightOf="@id/image0" 

        android:id="@+id/image1"/> 

   

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" 

        android:background="@drawable/icon" 

        android:layout_below="@id/image0" 

        android:layout_toLeftOf="@id/image0" 

        android:id="@+id/image1"/> 

   

        android:layout_width="wrap_content" 

        android:layout_height="wrap_content" 

        android:background="@drawable/icon" 

        android:layout_below="@id/image0" 

        android:layout_toRightOf="@id/image0" 

        android:id="@+id/image1"/> 

 

说明:

 

android:layout_above 将该控件的底部 至于给定Id的控件 之上

 

android:layout_below 将该控件的顶部至于给定ID的控件之下

 

android:layout_toLeftOf 将该控件的右边缘和给定ID的控件的左边缘对齐

 

android:layout_toRightOf将该控件的左边缘和给定ID的控件的右边缘对齐

 

 

 

android:layout_alignBaseline将该 控件的baseline 和给定ID的控件 的baseline对齐

 

android:layout_alignBottom将该控件的底部边缘与给定ID控件的底部边缘对齐

 

android:layout_alignLeft将该控件的左边缘与给定ID控件的左边缘对齐

 

android:layout_alignRight将该控件的右边缘与给定ID控件的右边缘对齐

 

android:layout_alignTop将该控件的顶部边缘与给定ID控件的顶部边缘对齐

 

 

 

android:alignParentBottom 如果该值为true,则将该控件的底部和父控件的底部对齐

 

android:layout_alignParentLeft 如果该什为true, 则将该控件的左边和父控件的左边对齐

 

android:layout_alignParentRight 如果该什为true, 则将该控件的右边和父控件的右边对齐

 

android:layout_alignParentTop 如果该什为true, 则将该控件的顶部和父控件的顶部对齐

 

 

 

android:layout_centerHorizontal如果值为真,该控件将被至于水平方向的中央

 

android:layout_inParent如果值为真,该控件将被至于父控件水平方向和垂直方向的中央

 

android:layout_centerVertical如果值为真,该控件将被至于垂直方向的中央

转载于:https://www.cnblogs.com/loveliying/p/3144456.html

更多相关文章

  1. android RelativeLayout属性和布局实例
  2. 安卓学习(初)第三章(3)(《第一行代码》)
  3. Android常用的基本控件
  4. [置顶] Android中以JAR形式封装控件或者类库
  5. 几个Android控件属性笔记
  6. 关于界面布局的一些小知识
  7. LAYOUT SHOW
  8. android布局文件属性说明(转)
  9. Android(安卓)UI布局之RelativeLayout

随机推荐

  1. android 机顶盒Launcher开发
  2. android应用程序制定皮肤
  3. Android更换RatingBar图片
  4. Android日志服务例子,将日志保存在文件中
  5. Android (滑动屏幕切换图片的实现)
  6. Android(安卓)系统固定Launcher的方法
  7. Android之获取、设置EditText的文本
  8. android数据库升级的措辞
  9. Android8.1隐藏状态栏电池图标
  10. Android如何拦截WebView之中的Post或者Ge