Shape of Android (rounded corner input box)

Source: Internet
Author: User

1 Introduction This article mainly introduces how to set the EditText rounded corner through shape. 2 shape settings

Shape_life_search.xmlPut it in the res/drawable folder.

<? Xml version = "1.0" encoding = "UTF-8"?> <Shape xmlns: android = "http://schemas.android.com/apk/res/android"> <! -- Angle --> <corners android: radius = "100dp"/> <! -- Fill color --> <solid android: color = "# ffffff"/> <! -- Stroke width and color --> <stroke android: color = "# cccacb" android: width = "1dp"/> </shape>


3. Use shape in the activity_main.xml main layout.
<LinearLayout 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" android: orientation = "vertical" android: background = "# f5f5f5" tools: ignore = "HardcodedText, ContentDescription"> <! -- Head start --> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: orientation = "horizontal" android: padding = "10dp" android: background = "# ff5a54"> <ImageView android: layout_width = "wrap_content" android: layout_height = "match_parent" android: src = "@ drawable/head_left"/> <TextView android: layout_width = "0dp" android: layout_height = "match_parent" android: layout _ Weight = "1" android: gravity = "center" android: text = "surrounding life" android: textStyle = "bold" android: textSize = "20sp" android: textColor = "@ android: color/white"/> <ImageView android: layout_width = "wrap_content" android: layout_height = "match_parent" android: src = "@ drawable/head_right"/> </LinearLayout> <! -- Head end --> <! -- Search start --> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: orientation = "vertical" android: layout_margin = "10dp"> <EditText android: id = "@ + id/search_edit" android: layout_width = "match_parent" android: layout_height = "wrap_content" android: drawableLeft = "@ drawable/search_left" android: background = "@ drawable/shape_life_search" android: hint = "Enter the merchant or address" and Roid: padding = "10dp" android: textColorHint = "# b7b7b7" android: textStyle = "bold"/> </LinearLayout> <! -- Search end --> <LinearLayout android: layout_width = "match_parent" android: layout_height = "wrap_content" android: orientation = "vertical"> <ImageView android: layout_width = "match_parent" android: layout_height = "match_parent"/> </LinearLayout>


4. Resource head_left.png used
Head_right.png
Search_left.png
5. Hide the title bar
Package com. ui; import android. app. activity; import android. OS. bundle; import android. view. window; public class MainActivity extends Activity {@ Override protected void onCreate (Bundle savedInstanceState) {super. onCreate (savedInstanceState); // hide the application title bar (you can see the notification bar on your phone) requestWindowFeature (Window. FEATURE_NO_TITLE); // set full screen (the notification bar is also hidden) // this. getWindow (). setFlags (WindowManager. layoutParams. FLAG_FULLSCREEN, WindowManager. layoutParams. FLAG_FULLSCREEN); setContentView (R. layout. activity_main );}}

6. Result Preview Preview the result in the simulator in eclipse





Note: Please indicate the source for reprinting. After all, the code is coded one by one ~


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.