1:在res文件夹下新建一个drawble文件夹,并新建一个背景文件如writebg.xml

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <shape xmlns:android="http://schemas.android.com/apk/res/android" >
  3. <!-- 设置圆角 -->
  4. <corners android:radius="5dip"/>
  5. <!-- 设置渐变色 -->
  6. <gradient android:startColor="@android:color/white"
  7. android:endColor="@android:color/holo_blue_bright"/>
  8. <!-- 设置边框颜色和宽度 -->
  9. <stroke android:width="1dp"
  10. android:color="@android:color/black"
  11. />
  12. </shape>

2: 在activity.xml文件中使用writebg.xml文件作为编辑框的背景,并设置字体位置

  1. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  2. xmlns:tools="http://schemas.android.com/tools"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"
  5. android:paddingBottom="@dimen/activity_vertical_margin"
  6. android:paddingLeft="@dimen/activity_horizontal_margin"
  7. android:paddingRight="@dimen/activity_horizontal_margin"
  8. android:paddingTop="@dimen/activity_vertical_margin"
  9. tools:context=".MainActivity" >
  10. <EditText
  11. android:layout_width="match_parent"
  12. android:gravity="center|right"
  13. android:layout_height="60dp"
  14. android:id="@+id/et_input"
  15. android:background="@drawable/writebg"
  16. android:editable="false"
  17. />
  18. </RelativeLayout>

3:在AndroidManifest.xml文件中设置第一个activity的主题背景

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3. package="com.thinker.caculatordemo"
  4. android:versionCode="1"
  5. android:versionName="1.0" >
  6.  
  7. <uses-sdk
  8. android:minSdkVersion="14"
  9. android:targetSdkVersion="18" />
  10.  
  11. <application
  12. android:allowBackup="true"
  13. android:icon="@drawable/ic_launcher"
  14. android:label="@string/app_name"
  15. android:theme="@style/AppTheme" >
  16. <activity
  17. android:name="com.thinker.caculatordemo.MainActivity"
  18. android:label="@string/app_name"
  19. <!-- 设置页面的主题背景 -->
  20. android:theme="@android:style/Theme.Black.NoTitleBar"
  21. >
  22. <intent-filter>
  23. <action android:name="android.intent.action.MAIN" />
  24.  
  25. <category android:name="android.intent.category.LAUNCHER" />
  26. </intent-filter>
  27. </activity>
  28. </application>
  29.  
  30. </manifest>

写一个背景渐变的TextView输入框的更多相关文章

  1. 用css来写一个背景图片的切换

    代码如下: <!DOCTYPE HTML> <htmllang="en-US"> <head> <meta charset="U ...

  2. 手把手教你写一个RN小程序!

    时间过得真快,眨眼已经快3年了! 1.我的第一个App 还记得我14年初写的第一个iOS小程序,当时是给别人写的一个单机的相册,也是我开发的第一个完整的app,虽然功能挺少,但是耐不住心中的激动啊,现 ...

  3. 教你写一个Android可快速复用的小键盘输入控件

    引子 在Android项目开发中特别是一些稍大型的项目,面对需求文档的时候你经常会发现很多地方用到了同样的组件,但是又略有不同.比如这个: 右边是一个小键盘输入板,左边当焦点不同的时候分别用右边的小键 ...

  4. android 开发 写一个RecyclerView布局的聊天室,并且添加RecyclerView的点击事件

    实现思维顺序: 1.首先我们需要准备2张.9的png图片(一张图片为左边聊天泡泡,一个图片为右边的聊天泡泡),可以使用draw9patch.bat工具制作,任何图片导入到drawable中. 2.需要 ...

  5. Android——ViewPager滑动背景渐变(自定义view,ViewPager)

    效果: ActivityBackgroundImage,java(自定义视图) package com.example.chenshuai.test322; import android.conten ...

  6. 从头写一个Cucumber测试(一) Selenium Test

    转载:https://yaowenjie.github.io/%E7%BC%96%E7%A8%8B%E7%9B%B8%E5%85%B3/cucumber-test, 背景(废话不读系列)   前段时间 ...

  7. DIY cnblog——背景渐变切换

    进来的小伙伴应该已经看过了我的博客样式,但还是贴张图先: 先大致说一下实现的思路,然后把代码贴出来供小伙伴们参考. 由于不是特别技术性的文章,格式就放宽松一点,跟着意识流走吧. 先跟大家分享一个渐变背 ...

  8. CSS不用背景图片实现优惠券样式反圆角,凹圆角,反向半圆角,并且背景渐变

    日常开发过程中,特别是商城相关应用开发过程中,时常会遇到花里胡哨的设计图,比如优惠券样式,上图: 实现思路如下:     1.先写一个外容器,实现背景色渐变: Html: 1 <div clas ...

  9. 如何用css写一个带斜切角、有边框又有内外阴影的按钮呢?

    如果有一天,UI设计师丢过来一张UI稿,上面有这样一个带有斜切角.有边框还有内外阴影的按钮,你会怎么实现呢?第一反应切图?可是按钮内容.大小都是可变的,那得切多少图啊~Canvas?SVG?No,no ...

随机推荐

  1. brief introduction JAVA new I/O (NIO)

    Reference document: Getting started with new I/O (NIO) Preface: NIO was introduced with JDK1.4 for h ...

  2. Groovy在不同JDK版本下的性能差异

    Groovy作为一种动态语言,性能和JAVA比肯定是差不少,根据网友的测试,由于测试环境,场景和编译参数的不同,大概有差2到7倍的差距 那么同样的Groovy,在不同的JDK版本下,会有着怎样的差异呢 ...

  3. Windows XP密钥(共38枚)

    翱翔博客(http://hi.baidu.com/guoguo6688/home) Windows XP Professional VOL版密钥:=========================== ...

  4. java selenium webdriver实战 页面元素定位

    自动化测试实施过程中,测试程序中常用的页面操作有三个步骤 1.定位网页上的页面元素,并存储到一个变量中 2.对变量中存储的页面元素进行操作,单击,下拉或者输入文字等 3.设定页面元素的操作值,比如,选 ...

  5. mysql 批量删除分区

    alter table titles drop partition p01; use zabbix; mysql> source drop_par.sql [oracle@oadb mysql] ...

  6. document.domain - JavaScript的同源策略问题:错误信息:Permission denied to access property 'document'_eecc00_百度空间

    document.domain - JavaScript的同源策略问题:错误信息:Permission denied to access property 'document'_eecc00_百度空间 ...

  7. IE 中开发,兼容与性能测试工具汇总

    前言 对于开发者来说, IE的兼容性是最让人头疼的. 因为是微软的产品, 且绑定在操作系统上, 所以IE的占用率还是相当大, 对于开发者来说, 这部分的兼容的考虑就不可避免了. 对于IE 的各版本来说 ...

  8. java 获取随机数的三种方法

    方法1(数据类型)(最小值+Math.random()*(最大值-最小值+1))例:(int)(1+Math.random()*(10-1+1))从1到10的int型随数 方法2获得随机数for (i ...

  9. 一些tcp通讯代码

    1,nginx-lua 需要设置nginx配置文件 resolver 223.5.5.5 223.6.6.6; lua_package_path "/usr/local/nginx/conf ...

  10. 第七届河南省赛G.Code the Tree(拓扑排序+模拟)

    G.Code the Tree Time Limit: 2 Sec  Memory Limit: 128 MB Submit: 35  Solved: 18 [Submit][Status][Web ...