zoukankan      html  css  js  c++  java
  • 3_1.9_注册页面_单选框_替换成图片

    切换到android模式--编码模式

    1 进入layout-选择Design模式
    2 先拉Layouts-vertical
    切换到Text模式--
    剪切xmlns:android="http://schemas.android.com/apk/res/android"
    删除之前样式


    4 radioGroup--再拉radioButton
    设置为wrap_content_根据内容包裹

    Text文本选择Phone点击进入后-默认输入法是数字

    4 Text-Plain Text普通文本

    -----------------

    更换默认复选框样式--为图片

    1 新建目录_drawable-new- drawable resource file
    切换studio为project模式
    app-src-main-res-右键
    android resource directory--drawables-hdpi
    hight dpi

    2 复制图片-粘贴到新目录

    3设置样式--drawable中新建check_img_style.xml样式文件

    4使用图片样式--切换到android开发模式-activity_form.xml的layout文件中

     android:button="@drawable/check_img_style"

    ------------------------------------------

    activity_form.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="vertical">

    <EditText
    android:id="@+id/editText3"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="phone"
    android:hint="请输入手机号"
    />

    <EditText
    android:id="@+id/editText"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPersonName"
    android:text=""
    android:hint="请输入用户名"
    />

    <EditText
    android:id="@+id/editText2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textPassword"
    android:hint="请输入密码"
    />

    <LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal">

    <CheckBox
    android:id="@+id/checkBox2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:button="@drawable/check_img_style"
    android:text="滑翔"
    />

    <CheckBox
    android:id="@+id/checkBox"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:button="@drawable/check_img_style"
    android:text="健身" />
    </LinearLayout>

    <RadioGroup
    android:layout_width="match_parent"
    android:layout_height="wrap_content"

    >

    <RadioButton
    android:id="@+id/radioButton2"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@null"
    android:button="@null"
    android:drawableLeft="@drawable/radio_img_style"
    android:text="男"

    />

    <RadioButton
    android:id="@+id/radioButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:background="@null"
    android:button="@null"
    android:drawableLeft="@drawable/radio_img_style"
    android:text="女"
    />

    </RadioGroup>

    <ToggleButton
    android:id="@+id/toggleButton2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/colorPrimary"
    tools:text="提交"
    android:textOff="关闭"
    android:textOn="开启" />

    <Switch
    android:id="@+id/switch1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:checked="false"
    android:text="自动续费"
    android:thumb="@android:color/transparent"
    android:button="@drawable/switcher_img_style"
    />


    </LinearLayout>

    ------------------------------------------------------------------


    FormActivity.java


    package com.example.init.changecolor;

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

    public class FormActivity extends AppCompatActivity {

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

    ---------------------------------------------------studio切换到project模式drawable

    check_img_style.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="true" android:drawable="@drawable/check_choose"></item> <!--放在第一位 -->
    <item android:drawable="@drawable/check_unchoose"></item>
    </selector>

    radio_img_style.xml

    <?xml version="1.0" encoding="utf-8"?>
    <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_checked="false" android:drawable="@drawable/radio_unchoose"/>
    <item android:state_checked="true" android:drawable="@drawable/radio_choose"/>
    <item android:state_selected="true" android:drawable="@drawable/radio_choose"/>
    <item android:state_pressed="true" android:drawable="@drawable/radio_choose"/>
    </selector>

  • 相关阅读:
    Debian安装autoconf
    Linux 解决 bash ./ 没有那个文件或目录 的方法
    C语言strtok()函数:字符串分割
    java.util.logging.Logger使用详解 (转)
    java中Logger.getLogger(Test.class)
    jquery ajax中success与complete的执行顺序 (转)
    navicat如何导入sql文件和导出sql文件
    MySQL修改root密码的多种方法(转)
    查看三种MySQL字符集的方法(转)
    mysql 5.7.13 安装配置方法图文教程(linux) (转)
  • 原文地址:https://www.cnblogs.com/bj-tony/p/10244613.html
Copyright © 2011-2022 走看看