• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

android studio,线性布局里的文字。跳转页面,图形设置。

武飞扬头像
张.阳欸
帮助3

文字设置,布局,引用。.xml

  1.  
    <?xml version="1.0" encoding="utf-8"?>
  2.  
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3.  
    xmlns:app="http://schemas.android.com/apk/res-auto"
  4.  
    xmlns:tools="http://schemas.android.com/tools"
  5.  
    android:layout_width="match_parent"
  6.  
    android:layout_height="match_parent"
  7.  
    android:orientation="vertical"
  8.  
    android:paddingTop="40dp"
  9.  
    android:background="@color/pik"
  10.  
    tools:context=".MainActivity">
  11.  
     
  12.  
    <TextView
  13.  
    android:id="@ id/tv_2"
  14.  
    android:layout_width="match_parent"
  15.  
    android:layout_height="wrap_content"
  16.  
    android:text="智慧城市"
  17.  
    android:textColor="#1D4DDC"
  18.  
    android:gravity="center"
  19.  
    android:layout_marginTop="100dp"
  20.  
    android:textSize="35sp" />
  21.  
     
  22.  
    <EditText
  23.  
    android:id="@ id/et_1"
  24.  
    android:layout_width="match_parent"
  25.  
    android:layout_height="50dp"
  26.  
    android:textColorHint="@color/red"
  27.  
    android:hint="用户名"
  28.  
    android:background="@drawable/username"
  29.  
    android:textSize="23sp"
  30.  
    android:layout_marginTop="20dp"
  31.  
     
  32.  
     
  33.  
    />
  34.  
    <EditText
  35.  
    android:id="@ id/et_2"
  36.  
    android:layout_width="match_parent"
  37.  
    android:layout_height="50dp"
  38.  
    android:textColorHint="@color/red"
  39.  
    android:hint="密码"
  40.  
    android:maxLines="1"
  41.  
    android:textSize="23sp"
  42.  
    android:inputType="textPassword"
  43.  
    android:layout_marginTop="10dp"
  44.  
    />
  45.  
    <LinearLayout
  46.  
    android:layout_width="wrap_content"
  47.  
    android:layout_height="wrap_content"
  48.  
    android:orientation="horizontal"
  49.  
    android:layout_gravity="center"
  50.  
    android:layout_marginTop="20dp"
  51.  
    >
  52.  
    <Button
  53.  
    android:id="@ id/bu_login"
  54.  
    android:layout_width="0dp"
  55.  
    android:layout_weight="1"
  56.  
    android:layout_height="wrap_content"
  57.  
    android:text="登录"
  58.  
    android:textSize="20sp"
  59.  
    android:layout_gravity="center"/>
  60.  
    <Button
  61.  
    android:layout_width="0dp"
  62.  
    android:layout_weight="1"
  63.  
    android:layout_height="wrap_content"
  64.  
    android:layout_marginLeft="30dp"
  65.  
    android:text="注册"
  66.  
    android:textSize="20sp"
  67.  
    android:backgroundTint="@color/red"
  68.  
    android:textColor="@color/white"
  69.  
    android:layout_gravity="center"/>
  70.  
    </LinearLayout>
  71.  
     
  72.  
     
  73.  
     
  74.  
     
  75.  
     
  76.  
     
  77.  
     
  78.  
    </LinearLayout>
学新通

页面跳转代码.java

  1.  
    package com.example.newtwo;
  2.  
     
  3.  
    import androidx.appcompat.app.AppCompatActivity;
  4.  
     
  5.  
    import android.content.Intent;
  6.  
    import android.os.Bundle;
  7.  
    import android.view.View;
  8.  
    import android.widget.Button;
  9.  
     
  10.  
    public class MainActivity extends AppCompatActivity {
  11.  
    //声明控件
  12.  
    private Button mlogin;
  13.  
     
  14.  
     
  15.  
     
  16.  
    @Override
  17.  
    protected void onCreate(Bundle savedInstanceState) {
  18.  
    super.onCreate(savedInstanceState);
  19.  
    setContentView(R.layout.activity_main);
  20.  
     
  21.  
    //找到控件
  22.  
    mlogin=findViewById(R.id.bu_login);
  23.  
    //实现跳转
  24.  
    mlogin.setOnClickListener(new View.OnClickListener() {
  25.  
    @Override
  26.  
    public void onClick(View v) {
  27.  
    Intent intent=new Intent(MainActivity.this,MainActivity2.class);
  28.  
    startActivity(intent);
  29.  
    }
  30.  
    });
  31.  
     
  32.  
     
  33.  
    }
  34.  
    }
学新通

设置图形外围,圆角,颜色。

  1.  
    <?xml version="1.0" encoding="utf-8"?>
  2.  
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
  3.  
    <stroke
  4.  
    android:width="1dp"
  5.  
    android:color="@color/red"
  6.  
    />
  7.  
    <corners
  8.  
    android:radius="10dp"
  9.  
    />
  10.  
     
  11.  
    </shape>

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfhfbgi
系列文章
更多 icon
同类精品
更多 icon
继续加载