安卓小工程

本周get一个新技能,做一个简单的安卓界面。
简单操作一哈!!!

1、打开eslipse->file->New->Android Application Project
随后就会弹出界面,填写安卓工程的名称。
!!!注意:Pakage Name 不可以出现中文哦

在这里插入图片描述

2、点击Next

在这里插入图片描述

3、点击Next,根据自己的喜好做以下设置。(看看英文就能了解是啥意思,自己设置哦)

在这里插入图片描述

4、全选默认就好,点击Next

在这里插入图片描述

5、依然选择默认,Finish

在这里插入图片描述

6、接下来就是愉快的代码时间

MainActivity.java

package com.example.android;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
    
}

activity_main.xml

<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=".MainActivity" >
    
<RelativeLayout 
    
    
    android:layout_width="match_parent"	
    android:layout_height="45dp"
    android:background="#D4B00B" 	//选择背景颜色
    
    >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello Wrold" 
        android:textSize="18sp"
        android:textColor="#ffffff"
        android:layout_centerVertical="true"
        android:layout_marginLeft="30dp"
        />

    
 
    </RelativeLayout>

    
    <RelativeLayout 
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_alignParentBottom="true"
        android:layout_marginBottom="50dp"
     
        >
        <Button 
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Welcome"
            android:textSize="25sp"
         
            android:textColor="#f0f0f0"
         
            />
        
    </RelativeLayout>
     

</RelativeLayout>


7、选择“Android”工程右键->Run As -> Android Application

连上手机试试效果

在这里插入图片描述

你成功了吗?
快去试试吧

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值