其他不多说,直接进入正题 1.界面效果如下: 2.src java文件 import android.app.Activity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.Spinner; public class TtActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.login); ((Spinner) findViewById(R.id.spinner1)) .setAdapter(new ArrayAdapter<Object>(this, android.R.layout.simple_spinner_item, new String[] { "我在线上", "Q我吧", "离开","忙碌","请勿打扰","隐身" })); } } 3.login.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas./apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/black"> <TableLayout android:id="@+id/tableLayout1" android:layout_height="wrap_content" android:layout_width="match_parent"> <!-- head row --> <TableRow android:id="@+id/tableRow5" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageButton android:id="@+id/imageButton1" android:src="@drawable/qq2011" android:layout_gravity="center" android:layout_width="320dp" android:layout_height="110dp"></ImageButton> </TableRow> <!-- center row --> <TableRow android:id="@+id/tableRow1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/white"> <TableLayout android:id="@+id/tableLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content"> <TableRow android:id="@+id/tableRow6" android:layout_width="wrap_content" android:layout_height="wrap_content"> <ImageButton android:src="@drawable/head" android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/imageButton2" android:background="@color/white" android:layout_marginLeft="10px" android:layout_marginTop="10px"></ImageButton> <LinearLayout android:orientation="vertical" android:id="@+id/linearLayout1" android:layout_height="wrap_content" android:layout_width="wrap_content" android:weightSum="1"> <!-- Layout --> <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="208dp"> <EditText android:layout_height="wrap_content" android:layout_weight="6.64" android:layout_width="170dp" android:id="@+id/numInput" android:layout_marginTop="20px"> <requestFocus></requestFocus> </EditText> <TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:text="@string/newnumber" android:layout_width="wrap_content" android:id="@+id/resige" android:layout_marginTop="25px" android:textColor="@color/dodgerblue"></TextView> </LinearLayout> <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="match_parent"> <EditText android:layout_height="wrap_content" android:layout_width="wrap_content" android:layout_weight="6.64" android:inputType="textPassword" android:id="@+id/pass"></EditText> <TextView android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceLarge" android:layout_width="wrap_content" android:id="@+id/findback" android:text="@string/findpass" android:textColor="@color/dodgerblue"></TextView> </LinearLayout> <!-- --> <LinearLayout android:layout_height="wrap_content" android:id="@+id/linearLayout2" android:layout_width="match_parent"> <LinearLayout android:id="@+id/linearLayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"> <Spinner android:id="@+id/spinner1" android:layout_height="wrap_content" android:layout_width="51dp"></Spinner> <CheckBox android:text="@string/remenberme" android:id="@+id/checkBox2" android:textColor="@color/black" android:layout_height="wrap_content" android:layout_width="wrap_content"></CheckBox> <CheckBox android:text="@string/auto" android:id="@+id/checkBox3" android:textColor="@color/black" android:layout_height="match_parent" android:layout_width="72dp"></CheckBox> </LinearLayout> </LinearLayout> </LinearLayout> </TableRow> <TableRow android:id="@+id/tableRow7" android:layout_width="wrap_content" android:layout_height="wrap_content"> <LinearLayout android:id="@+id/linearLayout3" android:layout_width="wrap_content" android:layout_height="wrap_content"> </LinearLayout> </TableRow> </TableLayout> </TableRow> <!-- bottom row --> <TableRow android:id="@+id/tableRow2" android:layout_width="wrap_content" android:background="@color/dodgerblue" android:layout_gravity="center" android:layout_height="120dp" android:layout_marginBottom="10px"> <LinearLayout android:id="@+id/linearLayout4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:weightSum="1" android:layout_gravity="center" android:layout_marginTop="10px" android:layout_marginBottom="10px"> <Button android:id="@+id/button2" android:text="@string/reset" android:layout_width="94dp" android:layout_weight="0.39" android:layout_height="wrap_content"></Button> <Button android:layout_width="94dp" android:id="@+id/log" android:text="@string/login" android:layout_marginLeft="101px" android:layout_weight="0.39" android:layout_height="wrap_content"></Button> </LinearLayout> </TableRow> </TableLayout> </LinearLayout> 4.values.string xml文件 <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">时间与日期</string> <string name="app_name">QQ2011</string> <string name="number">账号:</string> <string name="newnumber">注册</string> <string name="pass">密码:</string> <string name="findpass">找回</string> <string name="login">登录</string> <string name="reset">设置</string> <string name="remenberme">记住我</string> <string name="auto">自动登录</string> </resources> 5.配置AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas./apk/res/android" package="view.tt" android:versionCode="1" android:versionName="1.0"> <uses-sdk android:minSdkVersion="10" /> <application android:icon="@drawable/icon" android:label="@string/app_name"> <activity android:name=".TtActivity" android:label="@string/app_name"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest> 6.两张图片(head.png 和 qq2011.png)均是截图得来,可从本地截得,放在res.drawable-ldpi 下,如下图: |
|
来自: 昵称7823647 > 《Android开发》