找回密碼
 立即注冊(cè)

QQ登錄

只需一步,快速開(kāi)始

搜索
查看: 4061|回復(fù): 4
收起左側(cè)

android-studio詳細(xì)安裝步驟以及創(chuàng)建第一個(gè)項(xiàng)目

[復(fù)制鏈接]
ID:190577 發(fā)表于 2022-7-16 11:18 | 顯示全部樓層 |閱讀模式
1、首先我們?nèi)ス俜骄W(wǎng)站下載最新版的Android Studio,鏈接參考如下:
Download Android Studio and SDK tools  |  Android Developers
1.png
進(jìn)入網(wǎng)頁(yè)后,直接點(diǎn)擊網(wǎng)頁(yè)中心的“Download Android Studio
2、雙擊安裝軟件,打開(kāi)后點(diǎn)擊 Next 繼續(xù)下一步;
在安裝到第二步的時(shí)候,會(huì)出現(xiàn)以下界面
Android Virtual Device,是系統(tǒng)自帶模擬器,也可不用系統(tǒng)模擬器就不勾選,自己下載其他模擬器(這里我們勾選);
2.png
建議默認(rèn)安裝目錄,如果需要修改安裝目錄,可點(diǎn)擊 Browse…修改,點(diǎn)擊 Next 繼續(xù)下一步;(這里我們選擇默認(rèn)安裝目錄)
點(diǎn)擊 Install 安裝;
點(diǎn)擊 Next 繼續(xù)下一步;
點(diǎn)擊 Finish完成;
3、下載安裝完成后,我們打開(kāi)Android studio,會(huì)出現(xiàn)如下界面:
接下來(lái)選中“Empty Activity",點(diǎn)擊”Next“
3.png
接下來(lái)這個(gè)界面相信學(xué)習(xí)編程的都會(huì)很熟悉
4.png
其中Name就是項(xiàng)目名稱,需要注意名稱只能全英文。
Package 那么就是包的名稱,一般我都是選擇默認(rèn),不用管它。
Save location就是這個(gè)項(xiàng)目存儲(chǔ)的地方。
Language我這里選擇的是Java,還有一個(gè)Kotlin可供大家選擇,其他設(shè)置默認(rèn)即可,點(diǎn)擊Finish。稍等片刻,我們的項(xiàng)目就創(chuàng)建好了。
4、那么如何運(yùn)行我們的第一個(gè)項(xiàng)目呢,首先需要下載一個(gè)模擬器,點(diǎn)擊上方快捷菜單欄手機(jī)圖標(biāo)。
5.png


在這里可以選擇模擬器的信號(hào)和安卓版本,首先先創(chuàng)建一個(gè)新的模擬器
點(diǎn)擊最下角的Create Virtual Device...我們會(huì)進(jìn)入如下界面:
在這個(gè)界面可以選擇模擬器的型號(hào),需要注意的是,模擬器的型號(hào)和安卓版本的高低會(huì)影響下載的大小和響應(yīng)時(shí)長(zhǎng),在這里我建議配置較低的電腦選擇版本較低的模擬器和安卓版本。在這里我選擇的是Pixel 3 XL,點(diǎn)擊Next。
6.png
   接下來(lái)我們會(huì)進(jìn)入這個(gè)界面,在左邊的多選框里我們選擇的是安卓版本,在這里我下載的是安卓7.0(Nougat),點(diǎn)擊Next。
7.png
進(jìn)入這個(gè)界面一般都是默認(rèn)設(shè)置直接點(diǎn)擊Finish,如果你想要模擬器橫屏的話可以選中Lanscape,這里我是默認(rèn)選中的Portrait,點(diǎn)擊Finish。

5、接下來(lái)我們會(huì)來(lái)到最初的模擬器下載界面,可以看到剛剛下載的模擬器已經(jīng)出現(xiàn)在列表里了。剛剛下載的Pixel 3 XL API 24 2后面有一個(gè)按鈕,點(diǎn)擊它就可以啟動(dòng)模擬器啦。稍等片刻,模擬器就啟動(dòng)成功了。
9.png
6、那么如何運(yùn)行經(jīng)典的Hello World的呢,其實(shí)這個(gè)項(xiàng)目在創(chuàng)建時(shí)已經(jīng)替我們寫好了,在activity_main.xml文件里。

10.png

7、我們只需要點(diǎn)擊快捷菜單欄的小錘子用來(lái)編譯項(xiàng)目,中間的下拉表是用來(lái)選擇運(yùn)行那個(gè)項(xiàng)目,通常app就是當(dāng)前的主項(xiàng)目,右邊的三角形按鈕是用來(lái)運(yùn)行項(xiàng)目的。
11.png
8、至此,第一個(gè)項(xiàng)目就完成了。
12.png

評(píng)分

參與人數(shù) 1黑幣 +50 收起 理由
admin + 50 共享資料的黑幣獎(jiǎng)勵(lì)!

查看全部評(píng)分

回復(fù)

使用道具 舉報(bào)

ID:190577 發(fā)表于 2022-7-17 22:33 | 顯示全部樓層
android studio將背景設(shè)置為黑色或者白色的方法
File------setting--------appearance&Behavior
選擇theme為Darcula就會(huì)變成黑色主題;
選擇intellij 會(huì)變成白色主題
回復(fù)

使用道具 舉報(bào)

ID:190577 發(fā)表于 2022-7-18 15:44 | 顯示全部樓層
今天我們來(lái)學(xué)習(xí)下,常見(jiàn)的界面布局:
1.png
1、線性布局(LinearLayout)主要以水平或垂直方式來(lái)顯示界面中的控件。當(dāng)控件水平排列時(shí),顯示順序依次為從左到右,當(dāng)控件垂直排列時(shí),顯示順序依次為從上到下。
2.png
<?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>
3.png
<?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>
4.png

LinearLayout布局中的android:layout_width屬性值不可設(shè)為wrap_content。這是因?yàn)?/font>LinearLayout的優(yōu)先級(jí)比Button高,如果設(shè)置為wrap_content,則Button控件的android:layout_weight屬性會(huì)失去作用。android:layout_weight作用主要讓代碼適合不同的機(jī)型,我們按鈕1,按鈕2,按鈕3layout_weight屬性分別設(shè)置成1,1,2,它的含義寬度分別為1/4,1/4,2/4整個(gè)屏幕寬度。
<?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>
回復(fù)

使用道具 舉報(bào)

ID:190577 發(fā)表于 2022-7-18 15:46 | 顯示全部樓層
1.png


1、線性布局(LinearLayout)主要以水平或垂直方式來(lái)顯示界面中的控件。當(dāng)控件水平排列時(shí),顯示順序依次為從左到右,當(dāng)控件垂直排列時(shí),顯示順序依次為從上到下。 2.png
<?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>
3.png
<?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屬性值不可設(shè)為wrap_content。這是因?yàn)長(zhǎng)inearLayout的優(yōu)先級(jí)比Button高,如果設(shè)置為wrap_content,則Button控件的android:layout_weight屬性會(huì)失去作用。android:layout_weight的作用主要讓代碼適合不同的機(jī)型,我們按鈕1,按鈕2,按鈕3的layout_weight屬性分別設(shè)置成1,1,2,它的含義寬度分別為1/4,1/4,2/4整個(gè)屏幕寬度。
4.png
<?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>

回復(fù)

使用道具 舉報(bào)

ID:1087282 發(fā)表于 2023-7-5 09:35 | 顯示全部樓層
學(xué)習(xí)到了,感謝
回復(fù)

使用道具 舉報(bào)

本版積分規(guī)則

小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機(jī)教程網(wǎng)

快速回復(fù) 返回頂部 返回列表