android EditText 自定义边框 背景

安卓_重写Edittext,画边框 Android系统本身提供的TextView组件并不支持边框,但可以对edi进行扩展来添加边框。我们可以使用如下两种方法为TextView组件添加边框。1.  编写一个继承TextView类的自定义组件,并在onDraw事件方法中画边框。2.  使用9-patch格式的图像作为TextView的背景图来设置边框(这个背景图需要带一个边框)。在onDraw事件方法中画边框非常容易,只需要画TextV 阅读详情

自定义EditText边框背景:

 首先重新定义一个style。在values文件夹下新建一个xml文件:

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

        <resources>

            <style name="my_edittext_style" parent="@android:style/Widget.EditText">

                <item name="android:background">@drawable/my_edittext</item>

            </style>

         </resources>

       接下来在drawable里添加my_edittext.xml:内容如下

 <?xml version="1.0" encoding="utf-8"?>
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
 <item android:state_focused="true" android:drawable="@drawable/editbox_focus" />
        <item android:drawable="@drawable/editbox_normal" />

        </selector>

       其中editbox_normal为正常情况下的编辑框图片,editbox_focus为选中下的编辑框图片

     定义好了这两个文件之后就可以用以下方式使用:

    <EditText

      style="@style/my_edittext_style"

      android:text="My EditText"

      android:layout_width="fill_parent"

      android:layout_height="wrap_content">

    </EditText>

 

////////////////////////////////////

 

JAVA中这样写:setBackgroundDrawable(new BitmapDrawable(("bg_focus.png")));
EditText自定义边框背景与动态检测用户输入 一、EditText自定义边框背景 1.效果演示 2.代码实现 (1)res/drawable/shape_edit_normal.xml 功能:编辑框没获得焦点时,使用该shape。为根元素的ShapeDrawable资源,主要用于定义一个基本的几何图形,如矩形、圆形、线条等。     子元素用于指定填充集合图形的的颜色;     子元素用于定义几个图形的四个角的弧度 阅读详情

相关推荐

Matlab激活失败?手把手教你解决License checkout failed问题(附详细截图)

本文针对Matlab激活后出现“License checkout failed”错误的常见问题,提供了详细的解决方案。核心在于精准定位并正确填写Windows系统用户名,而非计算机名或账户全名。文章通过分步截图和命令指引,手把手教你使用`whoami`命令获取正确信息,并重新运行激活程序,从根本上解决因用户名填写错误导致的许可检查失败问题。

weixin_29062823的博客 570

android编辑框背景设计,如何在android中设置edittext的背景?

我找到了解决方案:text.xml:main.xml中:android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="vertical" >android:id="@+id/editText1"android:background="@drawable/text"andr...

weixin_36125588的博客 421

耕地质量评价软件实操指南:如何用Excel+ArcGIS一键生成土壤普查报告(附避坑技巧)

本文提供了一套融合Excel数据处理与ArcGIS空间分析的耕地质量评价实战工作流。详细讲解了从数据规范化预处理、高效数据桥接,到在ArcGIS中实现指标评分、综合指数计算与等级划分的全流程,旨在帮助土壤普查工作者大幅提升报告生成效率与准确性,并分享了关键的避坑技巧。

weixin_28455801的博客 489

安卓开发学习之013 EditText应用详解(样式、背景、光标、错误提示、自定义带删除按钮、无弹出菜单)

一、EditText简介 EditText是一个非常重要的组件,常用来作为用户输入的文本框组件 EditText是TextView的子类,可以看做是一个带有可编辑文本的TextView,所以TextView的方法和特性同样存在于EditText中,具体的TextView的介绍可以参考上一节“安卓开发学习之012 TextView高级应用”二、基本使用1. 限制最大输入字符个数 androi

Yu的专栏 4483

ASIC--DFT可测性设计工程师

DFT是什么? DFT是design for test(可测性设计)的缩写,就是在芯片设计过程中,加入可测性逻辑。有的公司把该职位归到前端设计,有的归到中端实现。 DFT职位大多分布于规模较大的数字IC设计公司里,因为大公司对芯片品质要求高,而且规模越大,芯片越贵,DFT就越复杂越重要。DFT主要是通过在芯片中加入可测性逻辑,等芯片制造出来,在ATE(AutomaticTestEquipmen...

TroubleMaker 2万+

逆向工程师必备:用MDL绕过游戏保护读取内存数据的完整流程(附POC代码)

本文深入探讨了内核级内存访问技术,重点介绍了如何利用MDL(Memory Descriptor List)机制稳定、隐蔽地绕过游戏反作弊系统读取进程内存。通过对比MmCopyVirtualMemory等方法的优劣,提供了完整的MDL映射实战代码与反检测策略,为逆向工程师在内核态进行安全内存操作提供了专业指导。

weixin_29227425的博客 623

EditText在应用中经常遇到的问题(改背景、缩进、去下划线、去焦点)--以绑定手机界面为例介绍

目录 缩进 去下划线 改背景 去焦点 整体样式: 改背景 bindingphone_btn_color.xml <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android="http://schemas.android.com/apk/res/android"> <corners android:radius="20dp"/> <solid android:co.

qq_50272406的博客 3975

Coffin-Manson模型的详细讲解

Coffin-Manson模型是一个简单而强大的工具,用于预测低循环疲劳寿命,尤其在半导体功率循环中评估热机械可靠性。其核心是通过应变(或温度变化)与循环次数的对数关系,实现加速测试和寿命外推。尽管有局限性,通过改进版本(如加入激活能),它在电子封装、焊点疲劳和器件设计中仍广泛应用。实际使用时,建议结合实验数据拟合参数,并验证模型预测。如果需要特定材料的参数值、代码实现或进一步计算示例,请提供更多细节!

专注于前沿技术的探索与实践,热衷于从代码逻辑、架构设计到行业应用等多维度深挖技术本质。期待在技术之路上与你共同成长~ 2144

[Android开发] 重学Android-EditText的进阶操作

EditText是我们常用的输入框控件,平常我们只是使用它输入文本,这里记录一些它不太常见的操作和一些解决方案。

Eqiqi的博客 1656

优秀的 Verilog/FPGA开源项目介绍(六)- MIPI

MIPI的协议我就不详细介绍了(可以查看<下面的二维码>),这里和开源方案比较接近的即使FPGA实现MIPI物理层(DPHY)中电气属性相关的几种方案:MIPI DPHY RX...

OpenFPGA的博客 4455

华为交换机系统软件升级和安全漏洞修复教程

在华为交换机国网可以查询到华为交换机官方电话:400-822-9999,通过下命令查询出需要升级的交换机软件版本和补丁版本号发给华为,获取新的升级系统软件和补丁以及升级教程。下面是我升级华为交换机总结的教程,作为参考。...

星如雨落 2964

Android EditText设置边框

Android EditText设置边框 简介 Android应用程序中给EditText设置边框。 效果图: 快速开始 在res/drawable目录下新建样式文件 edit_background.xml。 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns:android="http://schemas.an...

tracy的博客 3万+

习题加餐4. 冒险者工会

这个问题通过贪心算法解决,展示了贪心算法在解决一些优化问题中的强大能力。关键在于如何识别贪心选择的性质,并通过数学证明确保这种方法能够达到全局最优解。通过对问题的深入理解和逻辑推理,我们可以设计出有效的算法来解决问题,同时也需要注意代码实现中的细节,如排序和双指针的使用,以确保算法的效率和正确性。贪心算法的应用这个问题展示了贪心算法在实际问题中的应用。贪心算法通过在每一步选择当前最优的解决方案,期望最终达到全局最优解。该问题中,每次选择能力最接近但足以完成最难任务的冒险者,就是贪心选择的体现。

tang7mj的博客 1349

自定义android控件EditText 自定义边框 背景

自定义EditText边框背景: 首先重新定义一个style。在values文件夹下新建一个xml文件:                                       @drawable/my_edittext                                 接下来在drawable里添加my_edittext.

javaqun的博客 1029

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

自定义android控件EditText边框背景

在我们进行Android应用界面设计和时候,为了界面风格的统一,我们需要对一些控件进行自定义。比如我们的应用采用的蓝色风格,但是android的EditText控制获得焦点后显示的却是黄色的边框背景。那么如何让EditText在获得焦点的时候显示的是我们自定义的蓝色的背景呢? 首先准备两张图片,一张是EditText获得焦点后的边框背景,一张是没有获得焦点时的背景,注意制作成9.png样式的图片

jiaguo699的专栏 692

Android自定义EditText边框背景

  在res/drawable下创建3个xml文件,分别为: bg_edittext_normal.xml &lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;shape xmlns:android="http://schemas.android.com/apk/res/android"&gt; &lt;solid andro...

qq_26794809的博客 356

android dialog去掉边框颜色,自定义输入dialog,圆角边框,去掉底部黑色背景。去掉editText黄色输入框。...

一,先看看想要实现的dialog效果。 要实现这要的效果,我们需要几个应该注意的关键点:1,如何定义圆角边框。bg_title_custom_dialog.xml 四周都是圆角按钮。bg_bottom_custom_dialog.xml2,适当的场合设置透明背景颜色。EditText设置透明背景色去掉黄色边框。android:background="@color/transparent"#0000...

weixin_42359255的博客 719

使用图片自定义android控件EditText 边框背景

1 2 3 4 5 6 xml version="1.0" encoding="utf-8"?> resources>    style name="my_edittext_style" parent="@android:style/Widget.EditText">      item name="a

nizuoweiki的专栏 516
上一篇: android 模拟器上安装和卸载apk
下一篇: android 反编译
大禹
博客等级 码龄15年 1粉丝 8原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值