1-1.xml小部件

1.设置背景为图片
android:background="@drawable/main_background"
2.设置居中:
android:gravity="center"
3.设置距离左边的距离
android:layout_marginLeft/marginTop="15dp"/android:layout_marginRight="10dip"
4.设置字体大小
android:textSize="20sp"/android:textSize="8px"
5.TextView的宽带
android:width="60pt"
5.设置字体颜色
android:textColor="#000"
6.分割线
<View 
    android:layout_height="2px"
    android:background="#ff909090"
    >
7.RadioGroup设置默认选项
android:orientation="@+id/online"
8.得到按钮的id名称
but.getText().toString()
9.Toast提示对话框
Toast.makeText(this,"选择成功!",Toast.LENGTH_LONG).show();
10.设置输入对话框
<EditText
android:id="@+id/edit"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="请输入"
>
11.设置对话框为单行输入
android:singleLine="true"
12.设置对话框上有字
android:hint="请输入"
13.输入密码的对话框——比普通对话框多一行
android:password="true"
14..显示登录进度条——progressBar
<ProgressBar
android:id="@+id/jindutiao"
android:layout_width="30dp"
android:layout_height="30dp"
style="@style/MyProgressBar"
android:visibility="gone"
>
15.一个默认的小方框,用来设置选项-checkBox
<CheckBox
android:id="@+id/checkBox"
android:layout_width="Wrap-content"
android:layout_height="wrap_content"
android:text="关注作者微博?"
android:layout_marginRight="10dp"
andriod:textColor="#000"//黑色
android:checked="true"
>
16.图片按钮-ImageButton
<ImageButton
android:id="@+id/imageButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="38dp"
android:layout_marginTop="130dp"
android:src="@drawable/ic_image1"/>//通过引用设置按钮背景图片

17.由图片按钮状态改变图片
在“res/drawable-mdpi”目录下新建一个myselect.xml文件
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false"
      android:drawable="@drawable/ic_image1"/>
<item android:state_pressed="true"
	  android:drawable="@drawable/ic_image2"/></selector>
2.开关按钮
<ToggleButton
android:id="@+id/toggleButton"
android:layout_width="1500dp"
android:layout_height="80dp"
android:textOn="开"//选中时显示的文本
android:textOff="关"/>//未选中时显示的文本
 
3.自定义单选按钮对话框
(1)activity_selector.xml

<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"     android:paddingLeft="@dimen/activity_horizontal_margin"     android:paddingRight="@dimen/activity_horizontal_margin"     android:paddingTop="@dimen/activity_vertical_margin"     tools:context=".SelectorType" >

    <RadioGroup         android:id="@+id/group"         android:layout_width="wrap_content"         android:layout_height="wrap_content" >

        <RadioButton             android:id="@+id/button1"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:checked="true"             android:text="手机" />

        <RadioButton             android:id="@+id/button2"             android:layout_width="match_parent"             android:layout_height="wrap_content"             android:text="锁" />     </RadioGroup>

</RelativeLayout>

(2)SelectorActivity.java

package com.example.bluetooth2;

import java.util.zip.Inflater;

import android.os.Bundle; import android.app.Activity; import android.app.AlertDialog; import android.app.AlertDialog.Builder; import android.app.Dialog; import android.content.Context; import android.content.DialogInterface; import android.content.DialogInterface.OnClickListener; import android.view.LayoutInflater; import android.view.Menu; import android.view.View;

public class SelectorType extends Activity {

 @Override  protected void onCreate(Bundle savedInstanceState) {   super.onCreate(savedInstanceState);       Context context=SelectorType.this;    LayoutInflater inflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE);    View layout = inflater.inflate(R.layout.activity_selector_type, null);                new AlertDialog.Builder(this)             .setTitle("请选择设备类型:")              .setView(layout)               .setPositiveButton("确定",new OnClickListener(){

     public void onClick(DialogInterface dialog, int which) {      switch(which){      case R.id.button1:       break;      case R.id.button2:       break;      }               }      }).      setNegativeButton("取消",null).show();} }

 

 


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值