跳到主要內容

如何設置圓角的EditText——Android移動開發

 


首先定義一個圓角xml,路徑:res/drawable/rounded_edittext.xml

<?xml version="1.0" encoding="utf-8"?>

<shape xmlns:android="http://schemas.android.com/apk/res/android"

android:shape="rectangle" android:padding="10dp">

<solid android:color="#FFFFFF" />

<corners android:bottomRightRadius="15dp"

android:bottomLeftRadius="15dp" android:topLeftRadius="15dp"

android:topRightRadius="15dp" />

</shape>

 顯示控件的xml中

 <EditText android:id="@+id/edt_operator_name" style="@style/syncEditText"

android:hint="@string/hint_operator_name"

android:background="@drawable/rounded_edittext"

android:layout_width="250dip"

android:layout_height="wrap_content"

android:paddingTop="10dip"

android:paddingBottom="10dip"

android:gravity="center_vertical" />


其中關鍵的就是設置編輯文本控件的background屬性為剛定義的圓角xml。

即:

[java] view plaincopyprint?

  1. android:background="@drawable/rounded_edittext"  


留言

這個網誌中的熱門文章

PHP 登入網站示例 By ChatGPT

  PHP 登入網站示例 By ChatGPT 以下是一個簡單的 PHP 登入網站示例,包括登入頁面、驗證登入、登出功能: index.php (登入頁面) login.php (驗證登入) php <?php session_start ();  // 模擬用戶名和密碼,實際情況下需從數據庫或其他來源驗證 $valid_username = 'user' ; $valid_password = 'password' ;  // 檢查用戶提交的用戶名和密碼   if ( isset ( $_POST [ 'username' ], $_POST [ 'password' ]))  {  $username = $_POST [ 'username' ];  $password = $_POST [ 'password' ];  // 驗證用戶名和密碼是否正確   if ( $username === $valid_username && $password === $valid_password )  {  // 設置用戶會話   $_SESSION [ 'username' ] = $username ;  header ( 'Location: dashboard.php' );  // 登入成功,重定向到用戶主頁 exit ();   }  else   {  echo '用戶名或密碼錯誤' ;   }  }  ?> dashboard.php (用戶主頁) php Copy code <?php session_start ();  // 檢查用戶是否已登入,否則重定向到登入頁面   if (! isset ( $_SESSION [ 'username' ]))  {  header ( 'Location: index.php' );  exit ();  }  // 顯示用戶名 ...

PHP + MySQL 範例 By ChatGPT

  PHP + MySQL 範例 By ChatGPT 以下是一個簡單的 PHP + MySQL 範例,演示如何建立一個簡單的使用者註冊系統: 首先,創建一個名為 register.php 的 PHP 檔案,用於顯示註冊表單和處理用戶提交的註冊信息。 php <!DOCTYPE html> <html lang= "en" > <head> <meta charset= "UTF-8" > <title>User Registration</title> </head> <body> <h2>User Registration</h2> <form action= "register.php" method= "post" > <label for = "username" >Username:</label> <input type= "text" id= "username" name= "username" required><br><br> <label for = "password" >Password:</label> <input type= "password" id= "password" name= "password" required><br><br> <input type= "submit" value= "Register" > </form> <?php // 如果是 POST 請求,處理用戶註冊 if ( $_S...

Windows Ubuntu (WSL) 安裝 OpenClaw 保母級教學

Windows Ubuntu (WSL) 安裝 OpenClaw 保母級教學 🎮 OpenClaw 安裝保母級教學 專為 Windows Ubuntu (WSL) 環境打造。我們將一步步帶您從零開始,編譯並運行這款經典遊戲《Captain Claw (神之領域)》的開源引擎。無需專業背景,跟著點擊即可完成! ⏱️ 安裝流程預覽 整個安裝過程大約需要 15 到 20 分鐘 。大部分時間將花費在下載依賴套件以及編譯遊戲核心上。請確保您的網路連線穩定。 💡 必備條件: 已在 Windows 上安裝 WSL2 (Ubuntu),並且具備基礎的網路連線。 📁 額外準備: 您需要擁有原版《Captain Claw》的遊戲資源檔 (ASSETS 資料夾) 才能實際遊玩。 ...