zoukankan      html  css  js  c++  java
  • 假期学习记录14(TextView斜体字+渐变色+绑定点击事件)

    话不多说直接上代码,很简单

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"
        android:background="@drawable/mainbackground">
        <include
            layout="@layout/mytoolbar"
            />
        <TextView
            android:id="@+id/addMornWay"
            android:clickable="true"//点击事件需要设置这个
            android:gravity="center"
            android:textSize="40dp"
            android:textStyle="italic"
            android:text="添加早操路线"
            android:layout_width="match_parent"
            android:layout_height="100dp" />
        <TextView
            android:id="@+id/setNote"
            android:clickable="true"
            android:gravity="center"
            android:textSize="40dp"
            android:textStyle="italic"
            android:text="设置运动提醒"
            android:layout_width="match_parent"
            android:layout_height="100dp" />
        <TextView
            android:id="@+id/changePass"
            android:clickable="true"
            android:gravity="center"
            android:textSize="40dp"
            android:textStyle="italic"
            android:text="修改用户密码"
            android:layout_width="match_parent"
            android:layout_height="100dp" />
    </LinearLayout>
    package com.example.sportrecord;
    
    import android.content.Intent;
    import android.graphics.Color;
    import android.graphics.LinearGradient;
    import android.graphics.Shader;
    import android.support.v7.app.ActionBar;
    import android.support.v7.app.AppCompatActivity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.TextView;
    
    public class SetMess extends AppCompatActivity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_set_mess);
            ActionBar actionBar=getSupportActionBar();
            if(actionBar!=null){
                actionBar.hide();
            }
    
            TextView addMornWay = (TextView) findViewById(R.id.addMornWay);
            TextView setNote = (TextView) findViewById(R.id.setNote);
            TextView changePass = (TextView) findViewById(R.id.changePass);
    //下面两行设置字体渐变(上下渐变) LinearGradient mLinearGradient
    = new LinearGradient(0, 0, 0, addMornWay.getPaint().getTextSize(), Color.WHITE, Color.BLACK, Shader.TileMode.CLAMP); addMornWay.getPaint().setShader(mLinearGradient); LinearGradient mLinearGradient1 = new LinearGradient(0, 0, 0, setNote.getPaint().getTextSize(), Color.WHITE, Color.BLACK, Shader.TileMode.CLAMP); setNote.getPaint().setShader(mLinearGradient1); LinearGradient mLinearGradient2 = new LinearGradient(0, 0, 0, changePass.getPaint().getTextSize(), Color.WHITE, Color.BLACK, Shader.TileMode.CLAMP); changePass.getPaint().setShader(mLinearGradient2); addMornWay.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); setNote.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { } }); changePass.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent=new Intent(SetMess.this,ChangePassword.class); startActivity(intent); } }); } }
  • 相关阅读:
    C# List<T>排序总结
    转 SQL连接查询语句(内、外、交叉和合并查询)
    AngularJS实现数据列表的增加、删除和上移下移等功能实例
    在ASP.NET MVC项目中使用极验验证(geetest)
    WCF契约定义及主要用途
    用C#创建Windows服务(Windows Services)
    sqlserver事务加锁机制
    unicode-range特定字符使用font-face自定义字体
    Unicode范围预览
    中文汉字和常见英文数字等的unicode编码范围实例页面
  • 原文地址:https://www.cnblogs.com/837634902why/p/12314987.html
Copyright © 2011-2022 走看看