使用过Android不同版本,或者不同的Android的rom的同学应该都知道,Android的EditText的样式在不同它们上的显示是各式各样;

那我们能不能通过什么途径来让它们的样子统一起来呢?答案是肯定的...

这是我做的一个登录界面,虽然还有些粗糙,但是实现了输入框样式的统一;

我的实现思路是这样的(可能大家会有不同的方案,欢迎分享),首先定义一个RelativeLayout,然后再里面放一个ImageView,ImageView的背景色使用白色,高度确定,这里是120dp;

然后再定义一个EditText,不要背景(这样就实现了去掉输入框的边框),上方和左方与图片对齐;然后再弄一个分界线,我这里用的是ImageView 0.5dp,颜色是灰色;

下面在来一个EditText,左边和下边跟ImageView对齐;然后调节下字体颜色大小之类的,就完成了这个功能...

具体界面布局:

<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="fill_parent"    android:layout_height="fill_parent"    android:background="#1885DC"    android:gravity="center_horizontal"    android:orientation="vertical" >    <TextView        android:layout_width="wrap_content"        android:layout_height="wrap_content"        android:layout_marginTop="100dp"        android:text="@string/title"        android:textColor="@android:color/white"        android:textSize="36sp" />    <RelativeLayout        android:layout_width="fill_parent"        android:layout_height="wrap_content"        android:layout_marginLeft="20dp"        android:layout_marginRight="20dp"        android:layout_marginTop="30dp" >        <ImageView            android:id="@+id/img_bg"            android:layout_width="fill_parent"            android:layout_height="120dp"            android:background="#FFF"            android:contentDescription="@string/app_name" />        <EditText            android:id="@+id/et_username"            android:layout_width="match_parent"            android:layout_height="60dp"            android:layout_alignLeft="@+id/img_bg"            android:layout_alignTop="@+id/img_bg"            android:layout_marginLeft="10dp"            android:layout_marginRight="10dp"            android:background="@null"            android:hint="@string/hint_username"            android:inputType="number"            android:textSize="16sp" />        <ImageView            android:id="@+id/login_driver"            android:layout_width="match_parent"            android:layout_height="0.5dp"            android:layout_below="@+id/et_username"            android:layout_marginLeft="15dp"            android:layout_marginRight="15dp"            android:background="@android:color/darker_gray"            android:contentDescription="@string/app_name" />        <EditText            android:id="@+id/et_password"            android:layout_width="match_parent"            android:layout_height="60dp"            android:layout_alignBottom="@+id/img_bg"            android:layout_alignLeft="@+id/img_bg"            android:layout_below="@+id/et_username"            android:layout_marginLeft="10dp"            android:layout_marginRight="10dp"            android:background="@null"            android:hint="@string/hint_password"            android:inputType="textPassword"            android:textSize="16sp" />        <Button            android:onClick="login"            android:id="@+id/button_login"            android:layout_width="fill_parent"            android:layout_height="45dp"            android:layout_below="@+id/et_password"            android:layout_marginTop="5dp"            android:background="@drawable/login_button"            android:text="@string/login"            android:textColor="#FFF"            android:textSize="16sp" />        <Button            android:id="@+id/button_visit"            android:onClick="visit"            android:layout_width="fill_parent"            android:layout_height="45dp"            android:layout_below="@+id/button_login"            android:layout_marginTop="5dp"            android:background="@drawable/visitor_button"            android:text="@string/visitor"            android:textColor="#FFF"            android:textSize="16sp" />        <Spinner             android:layout_below="@+id/button_visit"            android:layout_width="match_parent"            android:layout_height="wrap_content"            android:id="@+id/banji_spinner"            android:visibility="gone"/>    </RelativeLayout></LinearLayout>












更多相关文章

  1. Android(安卓)入门第十讲02-广播(广播概述,使用方法(系统广播,自定义
  2. Android开发指南-用户界面-事件处理
  3. Android(安卓)zar高速扫码程序,(比zxing快很多倍),包更小,扫码界面Xml
  4. Android(安卓)UI编程之自定义控件初步(上)——ImageButton
  5. Android设计登录界面、找回密码、注册功能
  6. android 自定义闪退Dialog 收集闪退信息
  7. Android全局主题样式控制,语言设置、主题颜色、字体大小、字体样
  8. Android(安卓)用户界面---Android如何描画View(How Android(安卓)
  9. Android多媒体开发 Pro Android(安卓)Media 第二章 创建自定义相

随机推荐

  1. 使用codeigniter发布到wordpress.com博客
  2. 用简单的馅饼从原子进料中拉出
  3. php curl模拟登陆抓取数据
  4. php 自己做的简单论坛
  5. fgetcsv()错误地将双引号添加到第一行的第
  6. 将DOMDocument中的特定元素导出为字符串
  7. header("Content-type:text/html;charset
  8. 如果key在变量中,PHP如何从数组中获取值
  9. CakePHP错误:在Acl中找不到类'String'
  10. php 无限级分类 递归+sort排序 和 非递归