天天看点

记录一次安卓开发(登录界面的制作)

开发的是“我们约会吧”程序,

这个程序分为服务器端和客户端两部分。

客户端运行在安卓端,使用Android Studio开发;

服务器端运行在电脑端,使用Eclipse开发,数据库采用的是MySQL。

这个程序是在老师给出代码的基础上做的改进,

简单分各个部分简单,记录学到的内容。

1.先看成果:

①登录界面:

记录一次安卓开发(登录界面的制作)

登录界面设计的主要是界面的美观性,

这里对输入框和复选框进行了改进;

1.对输入框的改进:

①在layout/login.xml文件中:

<TableRow 
			android:gravity="center_horizontal"
			android:layout_width="wrap_content" 
			android:layout_height="wrap_content">
				<TextView 
					android:text="@string/tvUid"
					android:textColor="@drawable/black"
					android:textSize="16px"
					android:id="@+id/tvUid" 
					android:layout_width="60px"
					android:layout_height="40px"></TextView>
		
				<EditText  
					android:id="@+id/etUid" 
					android:textSize="16px"
					android:layout_width="200px" 
					android:layout_height="40px"
					android:background="@drawable/corner_round"></EditText>
		</TableRow>

		<TableRow 
			android:gravity="center_horizontal"
			android:layout_width="wrap_content" 
			android:layout_height="wrap_content">
			<TextView 
				android:text="@string/txPwd"
				android:textColor="@drawable/black"
				android:textSize="16px"
				android:layout_width="wrap_content" 
				android:layout_height="40px"></TextView>
		
			<EditText 
				android:id="@+id/etPwd" 
				android:textSize="16px"
				android:layout_width="wrap_content" 
				android:layout_height="40px"
				android:password="true"
				android:background="@drawable/corner_round"
			></EditText>
		</TableRow>
	</TableLayout >
           

②在drawable/corner_round.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
    <solid android:color="#D3D3D3"/>
    <stroke android:width="1dip" android:color="#fefefe"/>
    <corners android:radius="10dp"/>
    <padding android:bottom="10dp"
        android:left="10dp"
        android:right="10dp"
        android:top="10dp"/>
</shape>
           

这样就可以由更改为新的样式的输入框。

2.对复选框的改进:

①在layout/login.xml文件中:

<TableLayout 
		android:layout_width="fill_parent" 
		android:layout_height="wrap_content"
		android:collapseColumns="2"
		>
		<TableRow 
		    android:gravity="center_horizontal"
			android:layout_width="wrap_content" 
			android:layout_height="wrap_content">
			<CheckBox
  				android:id="@+id/cbRemember"
  				android:layout_width="132dp"
  				android:layout_height="20px"
  				android:text="@string/cbRemember"
  				android:textColor="@drawable/blue"
  				android:textSize="15px"
				style="@style/CustomCheckBoxTheme">
			</CheckBox>
			<CheckBox
  				android:id="@+id/myCheckBox_aload"
  				android:layout_width="132dp"
  				android:layout_height="20px"
  				android:text="自动登陆"
  				android:textColor="@drawable/blue"
  				android:textSize="15px"
				style="@style/CustomCheckBoxTheme"></CheckBox>
		</TableRow>
	</TableLayout>
           

②在values/style.xml文件中:

<style name="CustomCheckBoxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
		<item name="android:button">@drawable/checkbox_style</item>
		<item name="android:width">20px</item>
		<item name="android:height">20px</item>
	</style>
           

③在drawable/chebox_style.xml文件中:

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
        android:drawable="@drawable/yes"
        android:state_checked="true" />
    <item
        android:drawable="@drawable/no"
        android:state_checked="false"/>
    <item
        android:drawable="@drawable/no"/>
</selector>
           

其中使用的是drawable文件夹中的yes.png和no.png两张图片,图标图片可以去阿里巴巴矢量图标库中找有很多免费的图标图片。