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>