找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 2238|回复: 4
打印 上一主题 下一主题
收起左侧

android-studio详细安装步骤以及创建第一个项目

[复制链接]
跳转到指定楼层
楼主
1、首先我们去官方网站下载最新版的Android Studio,链接参考如下:
Download Android Studio and SDK tools  |  Android Developers
进入网页后,直接点击网页中心的“Download Android Studio
2、双击安装软件,打开后点击 Next 继续下一步;
在安装到第二步的时候,会出现以下界面
Android Virtual Device,是系统自带模拟器,也可不用系统模拟器就不勾选,自己下载其他模拟器(这里我们勾选);
建议默认安装目录,如果需要修改安装目录,可点击 Browse…修改,点击 Next 继续下一步;(这里我们选择默认安装目录)
点击 Install 安装;
点击 Next 继续下一步;
点击 Finish完成;
3、下载安装完成后,我们打开Android studio,会出现如下界面:
接下来选中“Empty Activity",点击”Next“

接下来这个界面相信学习编程的都会很熟悉
其中Name就是项目名称,需要注意名称只能全英文。
Package 那么就是包的名称,一般我都是选择默认,不用管它。
Save location就是这个项目存储的地方。
Language我这里选择的是Java,还有一个Kotlin可供大家选择,其他设置默认即可,点击Finish。稍等片刻,我们的项目就创建好了。
4、那么如何运行我们的第一个项目呢,首先需要下载一个模拟器,点击上方快捷菜单栏手机图标。


在这里可以选择模拟器的信号和安卓版本,首先先创建一个新的模拟器
点击最下角的Create Virtual Device...我们会进入如下界面:
在这个界面可以选择模拟器的型号,需要注意的是,模拟器的型号和安卓版本的高低会影响下载的大小和响应时长,在这里我建议配置较低的电脑选择版本较低的模拟器和安卓版本。在这里我选择的是Pixel 3 XL,点击Next。
   接下来我们会进入这个界面,在左边的多选框里我们选择的是安卓版本,在这里我下载的是安卓7.0(Nougat),点击Next。

进入这个界面一般都是默认设置直接点击Finish,如果你想要模拟器横屏的话可以选中Lanscape,这里我是默认选中的Portrait,点击Finish。

5、接下来我们会来到最初的模拟器下载界面,可以看到刚刚下载的模拟器已经出现在列表里了。刚刚下载的Pixel 3 XL API 24 2后面有一个按钮,点击它就可以启动模拟器啦。稍等片刻,模拟器就启动成功了。
6、那么如何运行经典的Hello World的呢,其实这个项目在创建时已经替我们写好了,在activity_main.xml文件里。


7、我们只需要点击快捷菜单栏的小锤子用来编译项目,中间的下拉表是用来选择运行那个项目,通常app就是当前的主项目,右边的三角形按钮是用来运行项目的。
8、至此,第一个项目就完成了。

评分

参与人数 1黑币 +50 收起 理由
admin + 50 共享资料的黑币奖励!

查看全部评分

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏1 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:190577 发表于 2022-7-17 22:33 | 只看该作者
android studio将背景设置为黑色或者白色的方法
File------setting--------appearance&Behavior
选择theme为Darcula就会变成黑色主题;
选择intellij 会变成白色主题
回复

使用道具 举报

板凳
ID:190577 发表于 2022-7-18 15:44 | 只看该作者
今天我们来学习下,常见的界面布局:

1、线性布局(LinearLayout)主要以水平或垂直方式来显示界面中的控件。当控件水平排列时,显示顺序依次为从左到右,当控件垂直排列时,显示顺序依次为从上到下。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello Wolrd!"
        android:textColor="#00ff00"
        android:textSize="28sp"
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮1"
        android:textSize="28sp" />
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮2" />
    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮3" />
</LinearLayout>
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".MainActivity">
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮1"
        android:textSize="28sp" />
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮3" />
</LinearLayout>


LinearLayout布局中的android:layout_width属性值不可设为wrap_content。这是因为LinearLayout的优先级比Button高,如果设置为wrap_content,则Button控件的android:layout_weight属性会失去作用。android:layout_weight作用主要让代码适合不同的机型,我们按钮1,按钮2,按钮3layout_weight属性分别设置成1,1,2,它的含义宽度分别为1/4,1/4,2/4整个屏幕宽度。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".MainActivity">
    <Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="10dp"
        android:text="按钮1"
         />
    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="10dp"
        android:text="按钮2" />
    <Button
        android:id="@+id/button3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="按钮3" />
</LinearLayout>
回复

使用道具 举报

地板
ID:190577 发表于 2022-7-18 15:46 | 只看该作者



1、线性布局(LinearLayout)主要以水平或垂直方式来显示界面中的控件。当控件水平排列时,显示顺序依次为从左到右,当控件垂直排列时,显示顺序依次为从上到下。
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context=".MainActivity">
    <TextView
        android:id="@+id/textView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="Hello Wolrd!"
        android:textColor="#00ff00"
        android:textSize="28sp"
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮1"
        android:textSize="28sp" />
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮2" />
    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮3" />
</LinearLayout>

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".MainActivity">
    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="按钮1"
        android:textSize="28sp" />
    <Button
        android:id="@+id/button2"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮2" />

    <Button
        android:id="@+id/button3"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="28sp"
        android:text="按钮3" />
</LinearLayout>

LinearLayout布局中的android:layout_width属性值不可设为wrap_content。这是因为LinearLayout的优先级比Button高,如果设置为wrap_content,则Button控件的android:layout_weight属性会失去作用。android:layout_weight的作用主要让代码适合不同的机型,我们按钮1,按钮2,按钮3的layout_weight属性分别设置成1,1,2,它的含义宽度分别为1/4,1/4,2/4整个屏幕宽度。

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context=".MainActivity">
    <Button
        android:id="@+id/button"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="10dp"
        android:text="按钮1"
         />
    <Button
        android:id="@+id/button2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:layout_marginRight="10dp"
        android:text="按钮2" />
    <Button
        android:id="@+id/button3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="按钮3" />
</LinearLayout>

回复

使用道具 举报

5#
ID:1087282 发表于 2023-7-5 09:35 | 只看该作者
学习到了,感谢
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表