Android UI元件使用
阿新 • • 發佈:2021-01-17
技術標籤:Android筆記androidandroid studioapp
Android UI元件使用
TextView:文字檢視
id指定id
width指定寬度
height指定高度
text指定文字內容
textcolo指定文字顏色
textsize指定字型大小
RadioGroup 單選擇框組
RadioButton 單選擇框
建立佈局部分程式碼顯示
<androidx.constraintlayout.widget.ConstraintLayout 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">
<EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="請輸入數字" android:textSize="20sp" android:textColor="@color/cardview_shadow_end_color" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="提交" android:textSize="20sp" tools:layout_editor_absoluteX="0dp" tools:layout_editor_absoluteY="580dp" /> <TextView android:layout_width="411dp" android:layout_height="50dp" android:layout_marginTop="340dp" android:hint="選擇你的愛好" android:textSize="20sp" app:layout_constraintTop_toTopOf="parent" tools:layout_editor_absoluteX="0dp" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="羽毛球" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="515dp" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="籃球" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="397dp" /> <CheckBox android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="足球" tools:layout_editor_absoluteX="16dp" tools:layout_editor_absoluteY="467dp" /> <ImageView android:id="@+id/imageView3" android:layout_width="414dp" android:layout_height="270dp" tools:layout_editor_absoluteX="-2dp" tools:layout_editor_absoluteY="59dp" tools:srcCompat="@tools:sample/backgrounds/scenic" />
</androidx.constraintlayout.widget.ConstraintLayout>
之後學習了Android 的相對應控制按鈕使之實現命令