Android--XML页面的编写

幼敏悟过人,读书辄成诵。这篇文章主要讲述Android--XML页面的编写相关的知识,希望能为你提供帮助。

Android--XML页面的编写

文章图片
     
Android--XML页面的编写

文章图片
   
Android--XML页面的编写

文章图片

 
  五个页面   代码如下:     图片资源链接:  https://pan.baidu.com/s/1jIoTDGE
  //   第一个
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/bg_main" android:padding="10dp" > < ImageView android:id="@+id/imageView1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentRight="true" android:src="https://www.songbingjia.com/android/@drawable/bt_setting_n" /> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_centerInParent="true" android:orientation="vertical" > < RelativeLayout android:onClick="onStart" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="@drawable/main_n" android:padding="10dp" > < ImageView android:id="@+id/iv_add" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:src="https://www.songbingjia.com/android/@drawable/medical_tijian_iv" /> < LinearLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginLeft="10dp" android:layout_toRightOf="@id/iv_add" android:orientation="vertical" > < TextView android:id="@+id/tv_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="手机体检" android:textColor="#fff" android:textSize="18sp" /> < TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="您已经很长时间没体检了" android:textColor="#fff" android:textSize="12sp" /> < /LinearLayout> < /RelativeLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:orientation="horizontal" > < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_backgroundm" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_injectsms" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_safesend" /> < /LinearLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:orientation="horizontal" > < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_traffic" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_notification" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_softwarem" /> < /LinearLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="2dp" android:orientation="horizontal" > < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_tools" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="2dp" android:layout_weight="1" android:background="@drawable/main_n" android:src="https://www.songbingjia.com/android/@drawable/bt_protection" /> < ImageView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" > < /ImageView> < /LinearLayout> < /LinearLayout> < /RelativeLayout>

 
  // 第二个
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/metro_default_bg" android:padding="20dp" > < RelativeLayout android:id="@+id/rl" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_alignParentRight="true" > < ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="https://www.songbingjia.com/android/@drawable/dd_user_default_icon_2x" /> < ImageView android:id="@+id/img_set" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_centerHorizontal="true" android:layout_marginBottom="20dp" android:src="https://www.songbingjia.com/android/@drawable/dd_zaker_setting_nor_2x" /> < ImageView android:id="@+id/img_1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/img_set" android:layout_centerHorizontal="true" android:layout_marginBottom="50dp" android:src="https://www.songbingjia.com/android/@drawable/dd_zaker_rss_nor_2x" /> < ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/img_1" android:layout_centerHorizontal="true" android:layout_marginBottom="50dp" android:src="https://www.songbingjia.com/android/@drawable/dd_zaker_faver_nor_2x" /> < /RelativeLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_marginRight="20dp" android:layout_toLeftOf="@id/rl" android:orientation="vertical" > < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:orientation="horizontal" > < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_weight="1" android:background="#60cccccc" android:clickable="true" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615532" android:gravity="center_horizontal" android:padding="30dp" android:text="考试动态" android:textColor="#fff" android:onClick="onStart2" android:textSize="15sp" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#60cccccc" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615531" android:gravity="center_horizontal" android:padding="30dp" android:text="提分经验" android:textColor="#fff" android:textSize="15sp" /> < /LinearLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:orientation="horizontal" > < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_weight="1" android:background="#60cccccc" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615530" android:gravity="center_horizontal" android:padding="30dp" android:text="学习周边" android:textColor="#fff" android:textSize="15sp" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#60cccccc" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615535" android:gravity="center_horizontal" android:padding="30dp" android:text="学霸社区" android:textColor="#fff" android:textSize="15sp" /> < /LinearLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginBottom="20dp" android:orientation="horizontal" > < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginRight="20dp" android:layout_weight="1" android:background="#60cccccc" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615534" android:gravity="center_horizontal" android:padding="30dp" android:text="投稿中心" android:textColor="#fff" android:textSize="15sp" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:background="#60cccccc" android:drawablePadding="15dp" android:drawableTop="@drawable/module_615533" android:gravity="center_horizontal" android:padding="30dp" android:text="天气助手" android:textColor="#fff" android:textSize="15sp" /> < /LinearLayout> < /LinearLayout> < /RelativeLayout>

 
// 第三、四、五
< RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@drawable/dfr" > < RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="50dp" android:gravity="center_horizontal" > < ImageView android:id="@+id/img" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="https://www.songbingjia.com/android/@drawable/anq" /> < TextView android:id="@+id/tv_music" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginLeft="10dp" android:layout_toRightOf="@id/img" android:text="酷狗音乐" android:textColor="#fff" android:textSize="28sp" /> < TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignBottom="@id/img" android:layout_below="@id/tv_music" android:layout_marginLeft="10dp" android:layout_toRightOf="@id/img" android:gravity="center" android:text="不 变 的 只 有 音 乐" android:textColor="#fff" android:textSize="14sp" /> < /RelativeLayout> < RelativeLayout android:id="@+id/rl_bottom" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:layout_marginBottom="20dp" > < TextView android:id="@+id/tv_qq" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerHorizontal="true" android:layout_marginLeft="40dp" android:layout_marginRight="40dp" android:drawablePadding="7dp" android:drawableTop="@drawable/b12" android:gravity="center" android:text="QQ" android:textColor="#fff" android:textSize="12sp" /> < TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toLeftOf="@id/tv_qq" android:drawablePadding="7dp" android:drawableTop="@drawable/b10" android:gravity="center" android:text="微博" android:textColor="#fff" android:textSize="12sp" /> < TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/tv_qq" android:drawablePadding="7dp" android:drawableTop="@drawable/dfi" android:text="微信" android:textColor="#fff" android:textSize="12sp" /> < /RelativeLayout> < LinearLayout android:id="@+id/ll" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_above="@id/rl_bottom" android:layout_marginBottom="20dp" android:orientation="horizontal" > < View android:layout_width="0dp" android:layout_height="1dp" android:layout_gravity="center" android:layout_marginLeft="20dp" android:layout_weight="2" android:alpha="0.3" android:background="@android:color/white" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginLeft="3dp" android:layout_marginRight="3dp" android:layout_weight="1" android:gravity="center" android:text="其他登录方式" android:textColor="#fff" android:textSize="14sp" /> < View android:layout_width="0dp" android:layout_height="1dp" android:layout_gravity="center" android:layout_marginRight="20dp" android:layout_weight="2" android:alpha="0.3" android:background="@android:color/white" /> < /LinearLayout> < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_above="@id/ll" android:layout_marginBottom="20dp" android:gravity="center_horizontal" android:orientation="vertical" > < ImageView android:id="@+id/img_login" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_marginBottom="8dp" android:layout_weight="1" android:src="https://www.songbingjia.com/android/@drawable/login" /> < ImageView android:id="@+id/img_register" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_weight="1" android:src="https://www.songbingjia.com/android/@drawable/register" /> < /LinearLayout> < /RelativeLayout>

【Android--XML页面的编写】 
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > < LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:background="@drawable/back" android:orientation="vertical" > < LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > < ImageView android:layout_margin="5dp" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:src="https://www.songbingjia.com/android/@drawable/kugou" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" android:gravity="center" android:text="听" android:textColor="#fff" android:textSize="18sp" /> < TextView android:layout_width="0dp" android:layout_height="wrap_content" android:layout_gravity="center_vertical" android:layout_weight="1" android:gravity="center" android:text="看" android:textColor="#fff" android:textSize="18sp"

    推荐阅读