第二十三天 TextView、Button

TextView

textViewPhone.setTextColor(Color.BLUE);//设置文本颜色
textViewPhone.setAutoLinkMask(Linkify.PHONE_NUMBERS);//拨打电话(android:autoLink="phone")
//上网(android:autoLink="web")
textViewPhone.setText("拨打电话:18500292306");//要写在setAutoLinkMask一句的后面
 textViewPrice=(TextView)findViewById(R.id.textViewPrice); textViewPrice.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG);//在text上加上中划线
 textViewImg=(TextView)findViewById(R.id.textView_img);
        String text="我是一个<font color='#ff0000'>富文本</font>,然后末尾加一个图标<img src='a_main_icon08'/>";
        Html.ImageGetter getter=new Html.ImageGetter() {
            @Override
            public Drawable getDrawable(String source) {
                int id=R.mipmap.ic_launcher;
                Class clazz=R.mipmap.class;
                try {
                    Field field = clazz.getDeclaredField(source);
                    id=field.getInt(clazz);
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }catch (NoSuchFieldException e) {
                    e.printStackTrace();
                }
                Drawable drawable=getResources().getDrawable(id);
                drawable.setBounds(0,0,drawable.getIntrinsicHeight(),drawable.getIntrinsicWidth());
                return drawable;
            }
        };
        Spanned spanned=Html.fromHtml(text,getter,null);
        textViewImg.setText(spanned);

这里写图片描述

文本滚动 界面小设计
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <TextView
        android:id="@+id/textView1"
        android:layout_width="200dp"
        android:layout_height="wrap_content"
        android:singleLine="true"
        android:ellipsize="marquee"//跑马灯
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:text="08-21 02:42:37.324  27265-27265/com.example.D/OpenGLRenderer﹕ TextureCache::get: create texture(0xb7d26868)"
        />

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:gravity="bottom">//置于底部
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:drawableTop="@mipmap/ic_launcher"
            android:text="消息"
            android:gravity="center_horizontal"
            android:layout_weight="1"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@mipmap/ic_launcher"
            android:text="联系人"
            android:gravity="center_horizontal"/>
        <TextView
            android:layout_width="0dp"
            android:layout_height="wrap_content"
            android:layout_weight="1"
            android:drawableTop="@mipmap/ic_launcher"
            android:text="动态"
            android:gravity="center_horizontal"/>
    </LinearLayout>
</RelativeLayout>

这里写图片描述

登录小界面

android:hint=”请输入密码” (EditText中的提示语)
password=true(密码不可见)

editText_password=(EditText)findViewById(R.id.editText_password);
Button button=(Button)findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
     @Override
     public void onClick(View v) {
     editText_password.setTransformationMethod(null);
     }
 });//设置密码可见

这里写图片描述

Button

ninepatch:上左代表拉伸、下右代表内容

当按下按钮时,按钮变成其他颜色(使用SDK下tools中的draw9patch工具编辑图片)
drawable
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@mipmap/back" android:state_pressed="true"/>
    <item android:drawable="@mipmap/picture9" />
</selector>
Button
 <Button
           android:layout_width="match_parent"
           android:layout_height="wrap_content"
           android:layout_gravity="center_horizontal"
           android:text="密码可见"
           android:id="@+id/button"android:background="@drawable/back_drawable"/>
RadioButton
public class MainActivity extends Activity {
    private RadioGroup mRadioGroup;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.radio_layout);
        mRadioGroup= (RadioGroup) findViewById(R.id.radioGroup);
        mRadioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                RadioButton rb= (RadioButton) findViewById(checkedId);
                Log.d("sex","您的性别是:"+rb.getText());
            }
        });
    }
}

这里写图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值