51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

【Android】常用界面布局·简单实现一个登录程序

登录程序

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:gravity="center_vertical|center_horizontal"
    android:orientation="vertical">
&amp;lt;TableLayout        // 表格布局 
    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;&amp;gt;

    &amp;lt;TableRow
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;

        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;账号&quot; /&amp;gt;

        &amp;lt;EditText
            android:id=&quot;@+id/etUser&quot;
            android:layout_width=&quot;200dp&quot; /&amp;gt;
    &amp;lt;/TableRow&amp;gt;

    &amp;lt;TableRow
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;&amp;gt;

        &amp;lt;TextView
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:text=&quot;密码&quot; /&amp;gt;

        &amp;lt;EditText
            android:id=&quot;@+id/etPass&quot;
            android:layout_width=&quot;200dp&quot; /&amp;gt;
    &amp;lt;/TableRow&amp;gt;
&amp;lt;/TableLayout&amp;gt;

&amp;lt;RelativeLayout       // 相对布局 
    android:layout_width=&quot;wrap_content&quot;
    android:layout_height=&quot;wrap_content&quot;&amp;gt;

    &amp;lt;Button
        android:id=&quot;@+id/btLogin&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:onClick=&quot;doClock&quot;
        android:text=&quot;登录&quot; /&amp;gt;

    &amp;lt;Button
        android:id=&quot;@+id/btExit&quot;
        android:layout_width=&quot;wrap_content&quot;
        android:layout_height=&quot;wrap_content&quot;
        android:layout_toRightOf=&quot;@id/btLogin&quot;
        android:onClick=&quot;doClock&quot;
        android:text=&quot;退出&quot; /&amp;gt;
&amp;lt;/RelativeLayout&amp;gt;

&amp;lt;FrameLayout    // 帧布局 
    android:layout_width=&quot;150dp&quot;
    android:layout_height=&quot;100dp&quot;&amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/tvSuccess&quot;
        android:layout_width=&quot;match_content&quot;
        android:layout_height=&quot;match_content&quot;
        android:gravity=&quot;center_vertical|center_horizontal&quot;
        android:text=&quot;登录成功&quot;
        android:textColor=&quot;#FF00FF00&quot;
        android:visibility=&quot;invisible&quot; /&amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/tvFail&quot;
        android:layout_width=&quot;match_content&quot;
        android:layout_height=&quot;match_content&quot;
        android:gravity=&quot;center_vertical|center_horizontal&quot;
        android:text=&quot;登录失败&quot;
        android:textColor=&quot;#FF00FF00&quot;
        android:visibility=&quot;invisible&quot; /&amp;gt;

    &amp;lt;TextView
        android:id=&quot;@+id/tvGo&quot;
        android:layout_width=&quot;match_content&quot;
        android:layout_height=&quot;match_content&quot;
        android:gravity=&quot;center_vertical|center_horizontal&quot;
        android:text=&quot;请登录&quot;
        android:textColor=&quot;#FF00FF00&quot; /&amp;gt;
&amp;lt;/FrameLayout&amp;gt;

&lt;/LinearLayout&gt;

&lt;/androidx.constraintlayout.widget.ConstraintLayout&gt;


赞(10)
未经允许不得转载:工具盒子 » 【Android】常用界面布局·简单实现一个登录程序