今天给各位分享java安卓登陆界面的知识,其中也会对java登陆界面进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
1、用java写一个手机商城注册界面代码2、android怎么做动态的登陆界面3、java制作一个android登陆界面 要求输入的密码非明文 怎么破?
用java写一个手机商城注册界面代码
这篇文章主要介绍了java通过JFrame做一个登录系统的界面完整代码示例,具有一定借鉴价值,需要的朋友可以参考下。
在java的JFrame内通过创建匿名对象的方式做登录界面
package com.sxt;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class LoginFrame extends JFrame{
JTextField txtname=new JTextField();
JPasswordField txtpass=new JPasswordField();
JButton bl=new JButton(“登录”);
JButton bg=new JButton(“关闭”);
//构造无参构造器把主要的方法放在构造器里,然后在main方法里面调
public LoginFrame(){
setBounds(25,25,250,250);
Container c = getContentPane();
c.setLayout(new GridLayout(4,2,10,10));
c.add(new JLabel(“用户名”));
c.add(txtname);
c.add(new JLabel(“密码”));
c.add(txtpass);
c.add(bl);
c.add(bg);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
//注意:此处是匿名内部类
bg.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
System.exit(0);
}
}
);
//注意:此处是匿名内部类
bl.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
android怎么做动态的登陆界面
设计android的登录界面的方法:
UI实现的代码如下:
1、背景设置图片:
background_login.xml
?xml version=”1.0″ encoding=”utf-8″?
shape xmlns:android=””
gradient
android:startColor=”#FFACDAE5″
android:endColor=”#FF72CAE1″
android:angle=”45″
/
/shape
2、圆角白框
效果图上面的并不是白框,其实框是白色的,只是设置了透明值,也是靠一个xml文件实现的。
background_login_div.xml
?xml version=”1.0″ encoding=”UTF-8″?
shape xmlns:android=””
solid android:color=”#55FFFFFF” /
!– 设置圆角
注意: bottomRightRadius是左下角而不是右下角 bottomLeftRadius右下角–
corners android:topLeftRadius=”10dp” android:topRightRadius=”10dp”
android:bottomRightRadius=”10dp” android:bottomLeftRadius=”10dp”/
/shape
3、界面布局:
login.xml
?xml version=”1.0″ encoding=”utf-8″?
LinearLayout
xmlns:android=””
android:orientation=”vertical”
android:layout_width=”fill_parent”
android:layout_height=”fill_parent”
android:background=”@drawable/background_login”
!– padding 内边距 layout_margin 外边距
android:layout_alignParentTop 布局的位置是否处于顶部 —
RelativeLayout
android:id=”@+id/login_div”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:padding=”15dip”
android:layout_margin=”15dip”
android:background=”@drawable/background_login_div_bg”
!– 账号 —
TextView
android:id=”@+id/login_user_input”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentTop=”true”
android:layout_marginTop=”5dp”
android:text=”@string/login_label_username”
style=”@style/normalText”/
EditText
android:id=”@+id/username_edit”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:hint=”@string/login_username_hint”
android:layout_below=”@id/login_user_input”
android:singleLine=”true”
android:inputType=”text”/
!– 密码 text —
TextView
android:id=”@+id/login_password_input”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/username_edit”
android:layout_marginTop=”3dp”
android:text=”@string/login_label_password”
style=”@style/normalText”/
EditText
android:id=”@+id/password_edit”
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
android:layout_below=”@id/login_password_input”
android:password=”true”
android:singleLine=”true”
android:inputType=”textPassword” /
!– 登录button —
Button
android:id=”@+id/signin_button”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_below=”@id/password_edit”
android:layout_alignRight=”@id/password_edit”
android:text=”@string/login_label_signin”
android:background=”@drawable/blue_button” /
/RelativeLayout
RelativeLayout
android:layout_width=”fill_parent”
android:layout_height=”wrap_content”
TextView android:id=”@+id/register_link”
android:text=”@string/login_register_link”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_marginLeft=”15dp”
android:textColor=”#888″
android:textColorLink=”#FF0066CC” /
ImageView android:id=”@+id/miniTwitter_logo”
android:src=”@drawable/cat”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_alignParentRight=”true”
android:layout_alignParentBottom=”true”
android:layout_marginRight=”25dp”
android:layout_marginLeft=”10dp”
android:layout_marginBottom=”25dp” /
ImageView android:src=”@drawable/logo”
android:layout_width=”wrap_content”
android:layout_height=”wrap_content”
android:layout_toLeftOf=”@id/miniTwitter_logo”
android:layout_alignBottom=”@id/miniTwitter_logo”
android:paddingBottom=”8dp”/
/RelativeLayout
/LinearLayout
4、java源代码,Java源文件比较简单,只是实例化Activity,去掉标题栏。
package com.mytwitter.acitivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.Window;
public class LoginActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.login);
}
}
5、实现效果如下:
java制作一个android登陆界面 要求输入的密码非明文 怎么破?
如果是密码非明文,只要在EditView中设置一个属性就可以了
android:password=”true”
不知道是不是你说的这种情况
希望能帮到你
关于java安卓登陆界面和java登陆界面的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。