天天看點

記錄一次安卓開發(登入界面的制作)

開發的是“我們約會吧”程式,

這個程式分為伺服器端和用戶端兩部分。

用戶端運作在安卓端,使用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兩張圖檔,圖示圖檔可以去阿裡巴巴矢量圖示庫中找有很多免費的圖示圖檔。