記事が長すぎるので、もう一度読むことをお勧めします!
私はそれが好きです。
最初のステップは、AndroidStudioを開くことです
ステップ2:空のアクティビティを作成する
ステップ3:プロジェクトを構成する
プロジェクト名(名前):あなたが持っているプロジェクトがわかりませんか?無意識のうちに死体を引き抜く
パッケージ名の命名規則:(ここでは私の命名規則を無視してください)
一般命名规则:
com.公司名.项目名.模块名....
对于个人项目,分为:
1.individual(个体):
指个体项目,由个人发起,但非个人独立完成,可公开或私有项目,版权属于发起人
形式:indi.发起者名.项目名.模块名....
2.personal (个人私人):
指个人项目,由个人发起,并独立完成,可分享的项目,版权属于个人
形式:pers.个人.项目名.模块名....
3.private(私人):
指私有项目,由个人发起并独立完成,不用于分享的非公开项目,版权属于个人
形式:priv.个人.项目名.模块名....
SaveLocation(プロジェクトアドレスを保存):
一般的に1つ作成します:ワークスペースディレクトリストレージ
言語
言語的には、ここでコトリンを選びましたが、結局グーグルが推奨する公用語であり、今後のトレンドでもあります。もちろん、Javaを置き去りにすることはできません。
このプロジェクトはインスタントアプリをサポートします:
このチェックにより、このプロジェクトで生成されたアプリは、appLinkを介して他のアプリに直接リンクできます。
AndroidXアーティファクトを使用します。
AndroidXAPIサポートライブラリを使用します。これをチェックする必要があります。そうしないと、以前のサポートパッケージを使用するときに多くのエラーが報告されます。最新のAndroidStudioがデフォルトでチェックされます。AndroidXは、Androidサポートライブラリのアップグレードです。AndroidサポートライブラリのAPIのパッケージ名はandroid.support。*の下にあり、AndroidXライブラリのすべてのAPIのパッケージ名はandroidx。*の下にあります。Androidサポートライブラリには、4.0より前のバージョンをサポートするAPIがいくつかあります。ただし、現在ほとんどのマシンはバージョン4.0以降であるため、新しいAndroidX APIサポートライブラリを使用でき、既存のアプリケーションはパッケージパスを変更するだけで済みます。
右上隅にある[実行]ボタンをクリックします。仮想マシンが見つからないため、作成する必要があります。ここで
このアイコンを選択し
、[新しい仮想デバイスの作成]をクリックします
ここにあなたが必要とするモデルを選ぶことです
ここに電話のシステムバージョンを選ぶために、私は最新のアンドロイド10.0を選びました
最後に、デバイスに名前を付けて終了することができます。
私は怠惰なので、通常、このような新しいアクティビティを作成します。。。設定する必要はありません
レイアウトファイルの生成をチェックするとはどういう意味ですか?
対応するレイアウトファイルがFirstActivity用に自動的に作成されることを示します。
ランチャーアクティビティをチェックするとはどういう意味ですか?
FirstActivityが現在のプロジェクトのメインアクティビティとして自動的に設定されることを示します。
直接終了するだけです。
Andriodレイアウト管理の詳細(1)-LinearLayout線形レイアウト
* Andriodには、LinearLayout
(線形レイアウト)、TableLayout
(テーブルレイアウト)、FrameLayout
(フレームレイアウト)、RelativeLayout
(相対レイアウト)、GridLayout
(グリッドレイアウト)、AbsoluteLayout
(絶対レイアウト)の6つのレイアウト方法があります。
LinearLayoutの一般的な属性の概要
属性1:android:orientation
線形レイアウトの方向を指定します(水平または垂直)
プロパティ2:android:width
線形レイアウトでのコンテナの幅
プロパティ3:android:height
線形レイアウトでのコンテナの高さ
プロパティ4:android:background
線形レイアウトの背景
プロパティ5:android:gravity
線形レイアウトで、親コンテナに対する子コンテナの位置
1プロパティ値:
android:orientation="horizontal" 指定线性布局方向:水平
android:orientation="vertical" 指定线性布局方向:垂直
2.属性値:
android:width="xxxdp"
指定线性布局的容器宽度为:xxxdp
android:width="wrap_content"
指定线性布局的容器宽度为:根据容器内容宽度大小来填充屏幕宽度
android:width="match_parent"
指定线性布局的容器宽度为:撑满整个屏幕宽度
3.属性値:
android:height="xxxdp"
指定线性布局的容器高度为:xxxdp
android:height="wrap_content"
指定线性布局的容器高度为:根据容器内容高度大小来填充屏幕高度
android:height="match_parent"
指定线性布局的容器高度为:撑满整个屏幕高度
4.属性値:
android:background="#000"
指定线性布局的背景为:黑色(rgb颜色)
android:background="@android:color/black"
指定线性布局的背景为:黑色(引用android系统自带的原始黑色)
andrid:backgrund="@color/colorPrimary"
指定线性布局的背景为:(根据res/color.xml 中的colorPrimary所定义的颜色设置)
5属性値:
android:gravity="center"
指定线性布局中,子容器相对于父容器所在的位置为:正中心
android:gravity="cente_verticalr"
指定线性布局中,子容器相对于父容器所在的位置为:垂直方向的正中心
android:gravity="center_horizontal"
指定线性布局中,子容器相对于父容器所在的位置为:水平方向的正中心
android:gravity="left"
指定线性布局中,子容器相对于父容器所在的位置为:最左边(默认)
android:gravity="right"
指定线性布局中,子容器相对于父容器所在的位置为:最右边
android:gravity="top"
指定线性布局中,子容器相对于父容器所在的位置为:最上方(默认)
android:gravity="bottom"
指定线性布局中,子容器相对于父容器所在的位置为:最下方
垂直方向:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn1"
android:textAllCaps="false" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn2"
android:textAllCaps="false" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn3"
android:textAllCaps="false" />
</LinearLayout>
水平方向:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn1"
android:textAllCaps="false" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn2"
android:textAllCaps="false" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="btn3"
android:textAllCaps="false" />
</LinearLayout>
線形方向:水平、垂直方向のコントロールの位置は、コントロールのandroid:layout_gravity属性の値によって変更できます。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="horizontal">
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:text="btn1"
android:textAllCaps="false" />
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="btn2"
android:textAllCaps="false" />
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:text="btn3"
android:textAllCaps="false" />
</LinearLayout>
直線方向:水平。コントロールのandroid:layout_weightプロパティを設定して、コントロールとコントロールの重み比を設定します。ここでは、EditTextコントロールとButtonコントロールの幅の比率を1:1に設定します。前提は次のとおりです。最初に、これら2つのコントロールのandroid:layout_width = "0dp"を設定する必要があります。
コード:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Type something" />
<Button
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="send"
android:textAllCaps="false" />
</LinearLayout>
EditTextコントロールのみの場合
android:layout_width =“ 0dp”
android:layout_weight =“ 1”
そしてボタンコントロール
android:layout_width = "wrap_content“”
android:layout_weight属性が設定されていません(ここでは設定されていないことに注意してください)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Type something" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="send"
android:textAllCaps="false" />
</LinearLayout>
android:id = "@ + id / xx"の理解
@ + id / height
"@"記号は、XMLパーサーが次の文字列を識別子に解析する必要があることを示しています。
「+」記号は、識別記号が追加されることを意味します。
「Id /」は、この識別子が「id」に分類されることを意味します。
「高さ」は、このインターフェースのメインの「android:id」です。
将来の手順では、「R.id.height」を使用してこのインターフェイスコンポーネントを取得します。したがって、「@ + id / height」は、対応するインターフェースコンポーネントを制御するために使用できる「height」という名前の識別子をここに作成したことを意味し、「R」クラスはこのインターフェースコンポーネントのアドレスを自動的に構成します。「R」クラスの内容は、「R.java」ファイルを表示することで見つけることができます。
見終わった?????