运用UI布局实现一个手机信息页面
效果图
下面说明操作步骤
1.将准备好的八个图标复制到res/drawable文件夹下
2.创建一个垂直的线性布局,并在线性布局中创建4个相对布局
<LinearLayoutxmlns: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="@android:color/darker_gray"
android:orientation="vertical"
tools:context=".MainActivity">
<RelativeLayout></RelativeLayout>
<RelativeLayout></RelativeLayout>
<RelativeLayout></RelativeLayout>
<RelativeLayout></RelativeLayout>
</LinearLayout>
注:
①tools:context=".MainActivity" :将这个 layout 文件和后面 的 MainActivity 进行关联,这样编辑器在展示布局效果的时候,就能针对MainActivity 的一些属性进行有针对性的处理。
②android:orientation="vertical":让四个相对布局垂直放置
3.添加style属性
<RelativeLayoutstyle="@style/h_wrap_content"
android:layout_marginTop="10dp">
注:
①RelativeLayout中的style="@style/h_wrap_content"引用的style.xml中的<style name="h_wrap_content">
样式 宽 match——parent 高 wrap_content
</