【Android初学者】UI组件 介绍

这篇博客主要为Android初学者介绍了UI组件的基础知识,包括TextView, EditText, Button, SeekBar, ProgressBar, RatingBar等。通过实例展示了如何创建和自定义这些组件,如设置自定义样式和颜色,以及实现功能如自动键盘切换、进度条控制字体大小和星星评价等。" 116372978,10549215,Oracle数据库中删除临时表空间TEMP2的故障解析与解决,"['数据库管理', 'Oracle故障排查', '表空间操作']
摘要由CSDN通过智能技术生成

UI组件:顾名思义,就是手机中常见的各种文本框,按钮,框架等待

常用的有
TextView,EditText ,Button, ImageView ,Dialog ,ListView ,GridView
以及用来包含这些的Layout
常用的Layout有LinearLayout RelativeLayout FrameLayout


这篇先介绍:

TextView ,EditTest,Button, 

音量调整条(SeekBar),

下载进度条直线型(ProgressBar),

加载进度条圆型(ProgressBar),

星星评价(RatingBar)
这几个。

如图:4个例子,6个方法,6个页面,

一个自定义样式mystyle,一个自定义颜色color,一张图片作为 图片按钮

主页:

     



主页面 功能代码:Maintivity.java

package com.open_open.uizujian;

import android.app.Activity;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void testOne(View view){
        Intent intent = new Intent(this,TestOneActivity.class);
        startActivity(intent);
    }
    public void testTwo(View view){
        Intent intent = new Intent(this,TestTwoActivity.class);
        startActivity(intent);
    }
    public void testThree(View view){
        Intent intent = new Intent(this,TestThreeActivity.class);
        startActivity(intent);
    }
    public void testFour(View view){
        Intent intent = new Intent(this,TestFourActivity.class);
        startActivity(intent);
    }
}

activity_main.xml

<?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:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_marginTop="10sp">
 <Button
     android:layout_width="match_parent"
     android:layout_height="wrap_content"
     android:text="TextView案例"
     android:onClick="testOne"
     style="@style/myButton"/>
<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="EditTest案例"
    android:onClick="testTwo"
    style="@style/myButton"/>

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Button案例"
    android:onClick="testThree"
    style="@style/myButton"/>

<Button
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="设置功能页面案例"
    android:onClick="testFour"
    style="@style/myButton"/>

    </LinearLayout>
</LinearLayout>



一、手机拔号,邮箱发件,链接地址

只要在autoLink 这里设置 就可以使用了。



代码:TestOneActivity.java

没有什么代码

package com.open_open.uizujian;

import android.app.Activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

public class TestOneActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test_one);
    }
}


页面:activity_test_one

<?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:orientation="vertical">

    <TextView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:text="这是一个文本"
        android:background="@android:color/holo_blue_light"
        style="@style/myTextVied"/>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="中国移动:
    15999999999"
    android:autoLink="phone"
    style="@style/myTextVied"/>

<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="站长邮箱:
    1056596328@qq.com"
    android:autoLink="email"
    style="@style/myTextVied"/>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="有事找百度:
    https://baudi.com"
    android:autoLink="web"
    style="@style/myTextVied"/>

</LinearLayout>
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值