导航:首页 > 操作系统 > android输入框边框

android输入框边框

发布时间:2022-08-22 09:47:29

1. 怎么给android 设置边框

Android是一种基于Linux的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板电脑。Android在开发过程中,很多情况下需要我们在TextView上面添加一个边框,但是TextView本身不支持边框,这里介绍几种设置边框的方法,可以供大家参考:

2. 怎么给android 设置边框

边框主要是使用shape文件,可以定制左右上下的边框,如果想要隐藏某部分,设置我透明即可。

3. Android studio3.0版本layout编辑显示界面,怎么设置手机边框

1.我们知道很多时候编辑框用来输入一行字符的时候会在下方有一条直线,此时是很美观的,但是如果要输入很长一段文字的文本编辑框时,一条横线就有失美观了,那么我们需要加上一个语句,让他有一个边框
android:background= "@android:drawable/edit_text"
2.inputType关于这个呢就是说你在光标点到编辑框里面的时候,手机会弹出来一个软键盘就是虚拟键盘,用来我们的输入,那这个其实就是,我理解哈,给用户更好的体验,像是意见啊之类的他肯定是全键盘或是九键盘可以输入字符的,那么对于输入手机号或是一串数字来说,那给他全键盘用户还要调到数字键盘上去,但是如果你直接给他数字键盘,他的用户体验是不是更好呢?
number是数字键盘,其中numeric可以是小数可以是整数;text就是有字母的全键盘、九键盘了;还可以是phone,这个跟那个数字的就比较接近了

4. android中edittext控件可以添加边框吗

可以。
1、将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,再设置background为@null
2、接下来就是一个空空的edittext了, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip。
代码:

<RelativeLayout 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:background="@android:color/darker_gray" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/white"
android:orientation="vertical" >

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="输入用户名"
android:paddingBottom="5dip"
android:paddingTop="5dip" />

<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@android:color/darker_gray" />

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="输入密码"
android:inputType="textPassword"
android:paddingBottom="5dip"
android:paddingTop="5dip" />
</LinearLayout>

</RelativeLayout>

5. android4.2开发怎样让文本框有边框

方法一:

比较土 ,加背景图片,透明的带边框的背景图片
设置到android:background就可以

方法二:
android:background的值是一个xml文件

yle="font-family: mceinline;">TextView的xml:

<TextView android:id="@+id/roomInfo"
android:layout_centerHorizontal="true"
android:textSize="24dip"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_alignParentRight="true"
android:textColor="@color/solid_black"
android:background="@drawable/setbar_bg"
android:layout_marginLeft="10dip"
android:layout_marginTop="5dip"
android:layout_width="300dip">
</TextView>

setbar_bg.xml 放在drawable-hdpi文件夹下面

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="#00000000"/>
<stroke android:width="2dip" android:color="#ff000000" />
</shape>

6. android 如何去掉edittext上边框

将edittext的style设置成?android:attr/textViewStyle 取消掉默认的样式,在设置background为@null接下来就是一个空空的edittext了(比如http://www.tiecou.com/)
, 在两个edittext中间加一个view,设置background为灰色,宽度match_parent,高度2dip看看。

RelativeLayout xmlns:android="

xmlns:tools="

android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/darker_gray" >

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@android:color/white"
android:orientation="vertical" >

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="输入用户名"
android:paddingBottom="5dip"
android:paddingTop="5dip" />

<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:background="@android:color/darker_gray" />

<EditText
style="?android:attr/textViewStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@null"
android:hint="输入密码"
android:inputType="textPassword"
android:paddingBottom="5dip"
android:paddingTop="5dip" />
</LinearLayout>
</RelativeLayout>

7. 怎么给android 设置边框

给view设置边框的代码:

1.创建xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >

2.设置<!-- 圆角 -->
<corners
android:radius="9dp"
android:topLeftRadius="2dp"
android:topRightRadius="2dp"
android:bottomLeftRadius="2dp"
android:bottomRightRadius="2dp"/><!-- 设置圆角半径 -->

3.设置<!-- 渐变 -->
<gradient
android:startColor="@android:color/white"
android:centerColor="@android:color/black"
android:endColor="@android:color/black"
android:useLevel="true"
android:angle="45"
android:type="radial"
android:centerX="0"
android:centerY="0"
android:gradientRadius="90"/>

4.设置<!-- 间隔 -->
<padding
android:left="2dp"
android:top="2dp"
android:right="2dp"
android:bottom="2dp"/><!-- 各方向的间隔 -->

5.设置大小精细<!-- 大小 -->
<size
android:width="50dp"
android:height="50dp"/><!-- 宽度和高度 -->

6.设置<!-- 填充 -->
<solid
android:color="@android:color/white"/><!-- 填充的颜色 -->

7.设置边框<!-- 描边 -->
<stroke
android:width="2dp"
android:color="@android:color/black"
android:dashWidth="1dp"
android:dashGap="2dp"/>
</shape>

8. android 如何让edittext控件显示边框

editText控件,边框其实是背景决定的,所以如果你的editText没有边框,可以通过以下两种方式解决:

  1. 给editText设置一个带边框的背景,可以是shape绘制一个corner和solid,也可以是用一个切好的.9图。

  2. 你应该是用的主题不对,把application的主题改成android:Theme.Light.NoTitleBar,editText的样式应该是有边框的那种了。

9. 怎么给android 设置边框

  1. android设置边框利用内容的margin或者padding的留白加容器的背景来实现边框效果。

  2. shape来实现边框效果

  3. corners是设置边框圆角

  4. stroke是描边的

  5. layer-list实现自由边框

嵌套一层,利用内容的margin或者padding的留白加容器的背景来实现边框效果。其实这个道理很简单,很早的时候那时候我们还用table做html页面布局的时候,我们就是使用cellspacing来实现table的边框的。现在我们也利用同样的想法来实现。

当然内部的容器也是需要有颜色的,如果想实现内部透明的效果则需要将内部View的背景色跟背景的颜色保持一致,这是不太方便的地方。


在Android中,给一个控件(或View)设置背景主要是通过background:xxx属性来完成。background的参数一般来说是一个drawable资源。


给控件设置边框最简单的方式就是把background设置成你预先设计好的带圆角和边框的背景图。但是这种方法的缺点是没有灵活性,不同大小的view要不同尺寸的图片,还要去适应不同分辨率的设备。


3使用9-patch(九宫格)的背景图片来实现边框效果。


做一个有边框的9-patch图片,作为要有边框的View的背景图即可。这样你还可以控制哪边有边框,哪边无边框,这种方法是比较好的一种方法,而且没有多余的View嵌套。另外你还可以实现圆角边框等效果。


4利用shape来实现边框效果。


当然你可以使用shape中的stroke来实现border的效果。


/res/drawable/filename.xml


只要引用这个shape作为背景图片即可。


5.layer-list实现自由边框

当前版本的Android

SDK并没有给stroke提供bottom、left、right之类的属性,也就是说你无法通过它来让长方形的边框少于4条。于是有人想出了这个方法。


android:width="1dp"


android:color="#333"/>


android:left="1dp"


android:top="1dp"


android:right="1dp"


android:bottom="1dp">


android:color="#FFF"/>


在第二个item中定义的top,left...就是对应的边框,不设置即没有边框。

阅读全文

与android输入框边框相关的资料

热点内容
安卓微信如何更换铃声 浏览:599
程序员谈判场在哪里 浏览:413
山东有线服务器中断云主机 浏览:472
java截取文件名 浏览:463
jquery教程pdf 浏览:164
三略pdf 浏览:584
spiflash单片机 浏览:11
阿里云的域名怎么解析到国外服务器 浏览:299
app客户端开发用什么服务器 浏览:293
台湾人能备案云服务器吗云空间 浏览:468
程序员小哥哥都喜欢动漫 浏览:374
如何用免费亚马逊云搭建服务器 浏览:665
php评论功能实现代码 浏览:526
犀牛中移动物件命令 浏览:788
程序员上班期间可以戴耳机吗 浏览:257
服务器启动卡怎么使用 浏览:796
逛了一天累趴了来一歌解压句子 浏览:347
谷歌app在哪里扫码 浏览:991
华为手环加密门禁卡怎么设置 浏览:734
pdf转xlsx 浏览:96