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 ~