生日贺卡制作过程
1.先确定整个界面的布局来选择使用什么Layout,因为是非线性布局所以选择RelativeLayout.
2.确定有那几个标签,一个ImageView,两个TextView
3.确定ImageView的属性,高度和宽度都是match_parent,将需要使用的图片添加到drawable文件夹下,然后再使用,图片的缩放模式是
CenterCrop会调图片的比例。
4.其中的一个TextView在Layout中的位置是在左上角,由于默认位置所以不需调整,另一个则在右下角需要这两个属性调位置。
android:layout_alignParentRight=”true” android:layout_alignParentBottom=”true”
5.剩下的TextView的属性两个就一样了,调整字号,调整字体,字体颜色,以及padding空白。
//下面是生日贺卡的代码
<?xml version="1.0" encoding="utf-8"?>
<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"
tools:context="com.example.ydh.myfapplication.MainActivity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"></RelativeLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/happy"
android:scaleType="centerCrop"
android:id="@+id/image" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Happy Birthday!"
android:textSize="36sp"
android:textColor="@android:color/white"
android:padding="8dp"
android:fontFamily="sans-serif-light" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="From yudhui"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:fontFamily="sans-serif-light"
android:textColor="@android:color/white"
android:padding="8dp"
android:textSize="36sp" />
</RelativeLayout>
成品图: