ken ouo
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # android 基本元件使用 ### TextView 文字 顯示指定的文字 <font color=#1936C9>**宣告**</font> ``` java= TextView text; ``` #### <font color=#1936C9>**常用的功能**</font> ``` xml= <TextView android:id="@+id/textview01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Hello World!" android:textSize="16dp" android:textColor="#FF0000" android:textStyle="bold" android:typeface="normal" <!-- 字型 --> android:padding="5dp" android:background="#CECECE" android:gravity="center" <!-- drawable樣式在文字的上/下/左/右邊 --> android:drawableBottom="@drawable/ic_android_black_24dp" android:drawableLeft="@drawable/ic_android_black_24dp" android:drawableTop="@drawable/ic_android_black_24dp" android:drawableRight="@drawable/ic_android_black_24dp" android:drawablePadding="10dp" /> ``` ``` java= //MainActivity內 TextView text1; text1 = findViewById(R.id.textview01); text1.setText("example text"); //文字內容 text1.setTextSize(16); //文字大小 text1.setTextColor(Color.WHITE); //文字顏色 text1.setBackgroundColor(Color.BLACK); //背景顏色 text1.setTypeface(Typeface.SANS_SERIF,Typeface.BOLD); //文字樣式 text1.setPadding(20,20,10,10); //文字和文字框的間距 text1.setWidth(300); //元件寬度 text1.setHeight(100); //元件高度 ``` ### <br>Button 按鈕 提供一個能讓使用者點擊的按鈕。 #### <font color=#1936C9>**宣告**</font> ``` java= Button btn; ``` #### <font color=#1936C9>**常用的功能**</font> ``` xml= <Button android:id="@+id/Button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" style="@style/CustomButton" <!-- 可以藉由themes.xml來自定義button --> android:drawableBottom="@drawable/ic_android_black_24dp" android:drawableLeft="@drawable/ic_android_black_24dp" android:drawableTop="@drawable/ic_android_black_24dp" android:drawableRight="@drawable/ic_android_black_24dp"/> ``` ``` xml= <resources xmlns:tools="http://schemas.android.com/tools"> <!-- Base application theme. --> <style name="Base.Theme.P2" parent="Theme.Material3.DayNight.NoActionBar"> <item name="colorPrimary">#B3B3B3</item> </style> <style name="Theme.P2" parent="Base.Theme.P2" /> <style name="CustomButton" parent="Widget.MaterialComponents.Button"> <item name="backgroundTint">#FFB7B7</item> <item name="cornerRadius">10dp</item> <item name="android:textColor">#FF4C4C</item> <item name="android:typeface">sans</item> <item name="textAllCaps">false</item> </style> </resources> ``` ``` java= //MainActivity內 Button; btn = findViewById(R.id.Button01); btn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { //點擊後的事件 } }); ``` ### <br>EditText 輸入 提供使用者輸入框輸入內容,再藉由EditText內部工具提出使用者輸入內容等,以達到程式與使用者的交互。 #### <font color=#1936C9>**宣告**</font> ``` java= EditText et; ``` #### <font color=#1936C9>**常用的功能**</font> ``` java= //layout的EditText內 android:textColor="#878787" //文字顏色 android:textSize="18dp" //文字大小 android:inputType="text" //輸入文字種類(text為文字、number為數字) android:hint="input" //提示文字 android:textStyle="bold" //粗體 android:background="@null" //隱藏輸入框底線 ``` ![截圖 2024-12-12 中午12.49.39](https://hackmd.io/_uploads/B1-_iJd4Jx.png) ``` java= //MainActivity內 EditText et; et = findViewById(R.id.EditText01); String s = text.getText().toString(); //取得輸入的內容 //還有監聽沒用 :P ``` <br> [TextInputLayout](https://ithelp.ithome.com.tw/m/articles/10291617) [EditText](https://ithelp.ithome.com.tw/m/articles/10261033)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully