Android studio做简单ui第一篇

第一篇 Android Studio 简单的登录ui

  • 第一步创建Android项目,选择一个空白模块在这里插入图片描述
  • 第二步,我们打开工程目录,找到与Src同级的build.gradle文件,把下面那个添加进去
  compile 'com.wrapp.floatlabelededittext:library:0.0.6'

例如:

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'
	
	
	
}
  1. 第三步,我们为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"
				style="@style/AppTheme"
				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>
  • 咱们现在开始写它的java文件

  • 我呢申明一下变量名

 //这里申明控件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绑定了现在我们开始具体操作
回答1: 为了创建Android Studio登录界面UI,您可以使用布局文件(例如XML)和控件(例如EditText和Button)。您可以使用工具栏和属性窗口来调整控件的外观和布局。您还可以使用Java代码来处理用户输入和登录操作。 回答2: Android StudioAndroid应用程序开发的强大工具,它集成了许多强大的特性和功能,可以帮助开发人员创建高质量的Android应用程序。 在任何应用程序中,主要界面是最先展现给用户看到的部分,尤其是启动时的登录界面,因此其UI设计显得尤为重要。以下是关于Android Studio登录界面UI设计的几点建议: 1. 颜色与图形 应该使用符合应用程序品牌的颜色、图形和其他设计元素。从品牌的标志和色彩中获取灵感,这将帮助保持应用程序的一致性和易于识别的标志性特征。同时也要避免使用过多亮丽刺眼的颜色,以保证用户的视觉体验。 2. 字体 选择易于阅读的字体和字号,尤其是在小屏幕上。对于标题和标签,可以选择粗体和高对比度的字体。对于正文,可以选择纤细的字体以节省空间,但也要注意阅读体验。 3. 布局与对齐 应该将元素布局得有秩序、明确、对称。可以采用网格布局、线性布局或相对布局等方式,以便将元素排列得整齐。对元素进行对齐和统一的间距调整,可以增强整个页面视觉上的呼应感。 4. 交互元素 添加交互元素,如按钮和输入框,并为其添加动画和效果,以增加交互体验。为了使用户更轻松地理解页面元素的意义,可以在按钮和输入框上添加标签或图标。 总的来说,登录界面的UI设计需要考虑到空间、流畅性以及色彩的呼吸感。精细的UI设计有助于给予用户正常的信心,同时也将第一印象到最佳。因此,设计精美而合理的Android Studio登录界面,将有助于增加应用的流行度和用户忠诚度。 回答3: Android Studio是Google官方发布的一款开发Android应用的IDE,设计一个优秀的登录界面UI对于应用的整体体验是非常重要的。下面将介绍如何设计一个符合UI设计原则的Android Studio登录界面UI。 首先,在设计登录界面时应该考虑到页面的结构和布局。一般情况下,登录界面的整体布局分为顶部、中部和底部三部分。顶部可以放置应用的Logo、标题等信息,中部是登录表单的主要区域,包括用户名、密码输入框和登录按钮,底部可以放置一些帮助信息等。 其次,登录界面的配色也非常重要,应该选择一种具有高度视觉感受的配色方案。要让登录界面看起来舒适、简洁,需要合理运用色彩,冷静自然的色彩能让人感到清新舒适,再加上与品牌色的搭配,不仅能增加品牌的识别度,同时还能提升应用的整体视觉效果。 第三,设计好字体样式与字号。用户名、密码、登录按钮等各元素所用的字体样式和字号要有规律,能让用户在浏览中容易找到他们感兴趣的点。字体样式应选择符合品牌特色和应用风格的字体,字号应考虑到易读性和界面美观度。 最后,用户体验是UI设计的核心。一个好的登录界面会让用户感到轻松、自然,从而产生信赖,并在之后继续使用应用。在实际设计过程中,可以适度地加入一些动画效果,在不影响页面整体感知度的前提下,提高用户对应用的使用体验。 总之,设计一个优秀的Android Studio登录界面UI需要考虑页面结构与布局、配色、字体样式与字号以及用户体验等方面,均衡地加以考虑,才能最终呈现出一个优秀的登录界面。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值