
compile 'com.wrapp.floatlabelededittext:library:0.0.6'@H_403_24@例如:apply plugin: 'com.androID.application'androID { compileSdkVersion 21 buildToolsversion "21.1.0" defaultConfig { applicationID "com.login.ui"//查看应用包名也是这里 minSdkVersion 14 targetSdkVersion 21 versionCode 1 versionname "1.0" } buildTypes { release { MinifyEnabled false proguardfiles getDefaultProguardfile('proguard-androID.txt'), 'proguard-rules.pro' } }}dependencIEs { compile filetree(dir: 'libs', include: ['*.jar']) //编辑框第三方库 compile 'com.wrapp.floatlabelededittext:library:0.0.6' }第三步,我们为XML文件添加布局 <?xml version="1.0" enCoding="utf-8"?><linearLayout xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:layout_wIDth="match_parent" androID:orIEntation="vertical" androID:ID="@+ID/activity_mainlinearLayoutuquyw" androID:layout_height="match_parent"> <linearLayout androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="match_parent"> <linearLayout androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="2" androID:gravity="center"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="Welcome" androID:ID="@+ID/activity_mainTextVIEw_Title" androID:textAppearance="?androID:attr/textAppearanceLarge" androID:textSize="42sp" androID:textStyle="bold"/> </linearLayout> <linearLayout androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="0dp" androID:layout_weight="8" androID:gravity="center_horizontal"> <linearLayout androID:orIEntation="vertical" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center"> <linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center" androID:padding="5dp" androID:layout_marginleft="20dp" androID:layout_marginRight="20dp"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="账号:" androID:textSize="20sp"/> <!--这个是第三方库的控件,如果机房的电脑不支持就把它删掉,是可以正常运行的,下头还有一个也得删掉--> <com.wrapp.floatlabelededittext.floatLabeledEditText androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <EditText androID:layout_wIDth="match_parent" androID:ems="10" androID:digits="1234567890" androID:hint="请输入账号" androID:layout_height="wrap_content" androID:maxLength="14" androID:lines="1" androID:ID="@+ID/activitymainEditText1"/> </com.wrapp.floatlabelededittext.floatLabeledEditText>- </linearLayout> <linearLayout androID:orIEntation="horizontal" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="center" androID:layout_marginleft="20dp" androID:layout_marginRight="20dp" androID:padding="5dp"> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="密码:" androID:textSize="20sp"/> <com.wrapp.floatlabelededittext.floatLabeledEditText androID:layout_wIDth="match_parent" androID:layout_height="wrap_content"> <EditText androID:layout_wIDth="match_parent" androID:hint="请输入密码" androID:lines="1" androID:maxLength="14" androID:ems="10" androID:digits="qwertyuiopasdfghjklzxcvbnm1234567890" androID:layout_height="wrap_content" androID:inputType="textWebPassword" androID:ID="@+ID/activitymainEditText2"/> </com.wrapp.floatlabelededittext.floatLabeledEditText> </linearLayout> <TextVIEw androID:layout_wIDth="wrap_content" androID:layout_height="wrap_content" androID:text="账号或密码错误" androID:visibility="invisible" androID:textcolor="#FF5252" androID:ID="@+ID/activity_mainTextVIEw_hkkkk"/> <button androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:text="登录" androID:layout_marginBottom="10dp" androID:background="@drawable/Shape" androID:layout_marginleft="30dp" androID:layout_marginRight="30dp" androID:ID="@+ID/activitymainbutton1"/> </linearLayout> <linearLayout androID:orIEntation="horizontal" androID:ID="@+ID/activity_mainlinearLayout" androID:layout_wIDth="match_parent" androID:layout_height="wrap_content" androID:gravity="right"> <TextVIEw androID:layout_wIDth="wrap_content" androID:textStyle="italic" androID:layout_height="wrap_content" androID:text="没有账号?前往注册" androID:layout_marginRight="30dp" androID:ID="@+ID/activitymainTextVIEw1"/> </linearLayout> </linearLayout> </linearLayout></linearLayout>我们定义好xml文件后,里面有一个button的背景是个资源文目录下的一个文件,那我们就去src/main/res/drawable下创建Shape.xml文件 <?xml version="1.0" enCoding="utf-8"?><shape xmlns:androID="http://schemas.androID.com/apk/res/androID" androID:shape="rectangle"> <!-- 填充的颜色 --> <solID androID:color="#64B5F6" /> <!-- androID:radius 弧形的半径 --> <!-- 设置按钮的四个角为弧形 --> <corners androID:radius="30dp" /> </shape>@H_403_24@咱们现在开始写它的java文件@H_403_24@我呢申明一下变量名 //这里申明控件ID,可以随便设,下头绑定就行了 .getText().toString() private button bn_uigo; //登录按钮 private TextVIEw t1,t2; //设置t1为标题 t2为注册前往 private EditText edi1,edi2; //两个编辑框 edi1为账号 edi2为密码 private String Accoun,password;//设定账号和密码 private String TAG; //定义打印数据--用来测试 private TextVIEw t3;//可以和上面设在一起,我这里单独设一个,好分类一些,这个ID用来绑定"账号或密码错误",这个textvIEw private linearLayout linhhhhhh;//进入软件加载一下动画效果 private linearLayout linu;//注册textvIEw父控件,这里创建它为了给它动画 private SharedPreferences mshart;咱们再给这些定义的变量绑定起来//绑定控件 bn_uigo = findVIEwByID(R.ID.activitymainbutton1); //按钮 t1 = findVIEwByID(R.ID.activity_mainTextVIEw_Title); //标题 t2 = findVIEwByID(R.ID.activitymainTextVIEw1); //注册textvIEw edi1 = findVIEwByID(R.ID.activitymainEditText1); //账号编辑框 edi2 = findVIEwByID(R.ID.activitymainEditText2); //密码编辑框 t3 = findVIEwByID(R.ID.activity_mainTextVIEw_hkkkk); //提示账号或密码错误 linhhhhhh = findVIEwByID(R.ID.activity_mainlinearLayoutuquyw);//linearlayout动画效果,你可以点R.ID.后面那个,直接跳转到它对应ID位置 linu = findVIEwByID(R.ID.activity_mainlinearLayout);把申明的量与xml的ID绑定了现在我们开始具体 *** 作 总结 以上是内存溢出为你收集整理的Android studio做简单ui第一篇全部内容,希望文章能够帮你解决Android studio做简单ui第一篇所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)