找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 3789|回復(fù): 4
打印 上一主題 下一主題
收起左側(cè)

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

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
1、首先我們?nèi)ス俜骄W(wǎng)站下載最新版的Android Studio,鏈接參考如下:
Download Android Studio and SDK tools  |  Android Developers
進(jìn)入網(wǎng)頁后,直接點(diǎn)擊網(wǎng)頁中心的“Download Android Studio
2、雙擊安裝軟件,打開后點(diǎn)擊 Next 繼續(xù)下一步;
在安裝到第二步的時(shí)候,會出現(xiàn)以下界面
Android Virtual Device,是系統(tǒng)自帶模擬器,也可不用系統(tǒng)模擬器就不勾選,自己下載其他模擬器(這里我們勾選);
建議默認(rèn)安裝目錄,如果需要修改安裝目錄,可點(diǎn)擊 Browse…修改,點(diǎn)擊 Next 繼續(xù)下一步;(這里我們選擇默認(rèn)安裝目錄)
點(diǎn)擊 Install 安裝;
點(diǎn)擊 Next 繼續(xù)下一步;
點(diǎn)擊 Finish完成;
3、下載安裝完成后,我們打開Android studio,會出現(xiàn)如下界面:
接下來選中“Empty Activity",點(diǎn)擊”Next“

接下來這個(gè)界面相信學(xué)習(xí)編程的都會很熟悉
其中Name就是項(xiàng)目名稱,需要注意名稱只能全英文。
Package 那么就是包的名稱,一般我都是選擇默認(rèn),不用管它。
Save location就是這個(gè)項(xiàng)目存儲的地方。
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)。


在這里可以選擇模擬器的信號和安卓版本,首先先創(chuàng)建一個(gè)新的模擬器
點(diǎn)擊最下角的Create Virtual Device...我們會進(jìn)入如下界面:
在這個(gè)界面可以選擇模擬器的型號,需要注意的是,模擬器的型號和安卓版本的高低會影響下載的大小和響應(yīng)時(shí)長,在這里我建議配置較低的電腦選擇版本較低的模擬器和安卓版本。在這里我選擇的是Pixel 3 XL,點(diǎn)擊Next。
   接下來我們會進(jìn)入這個(gè)界面,在左邊的多選框里我們選擇的是安卓版本,在這里我下載的是安卓7.0(Nougat),點(diǎn)擊Next。

進(jìn)入這個(gè)界面一般都是默認(rèn)設(shè)置直接點(diǎn)擊Finish,如果你想要模擬器橫屏的話可以選中Lanscape,這里我是默認(rèn)選中的Portrait,點(diǎn)擊Finish。

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


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

評分

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

查看全部評分

分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏1 分享淘帖 頂 踩
回復(fù)

使用道具 舉報(bào)

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

使用道具 舉報(bào)

板凳
ID:190577 發(fā)表于 2022-7-18 15:44 | 只看該作者
今天我們來學(xué)習(xí)下,常見的界面布局:

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

5#
ID:1087282 發(fā)表于 2023-7-5 09:35 | 只看該作者
學(xué)習(xí)到了,感謝
回復(fù)

使用道具 舉報(bào)

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

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

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

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