Android 中小细节

Android中小细节;


1.android:screenOrientation="portrait";

当在AndroidManifest.xml文件中定义了android:screenOrientation="portrait",就表示当我们切换横竖屏的时候,屏幕的内容始终以竖屏显示,

而不会根据屏幕的方向来显示内容。


2.dimens.xml 定义尺寸


3.在AndroidManifest.xml中隐藏标题栏,给整个程序设置主题

 <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar">

4.gravity和layout_gravity的区别

      android:gravity 属性是对该view中内容的限定.比如一个button 上面的text. 你可以设置该text 相对于view的靠左,靠右等位置.
      android:layout_gravity  是用来设置该view相对
与父view的位置.比如一个button 在linearlayout里,你想把该button放在linearlayout里靠左、

      靠右等位置就可以通过该属性设置

5.digits限制输入的字符

      android:digits="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

6.tools:context=".MainActivity"的作用

<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:background="#EEEEE0"
   
tools:context=".MainActivity">

   该页面使用和mianactivity一样的主题样式

7.pdlogin.setCancelable(false)的作用

   pdlogin.setCancelable(false);为false时按返回键能退出,默认为true,可以退出


8.动态设置控件的长宽高

   mImageView = (ImageView) rl.findViewById(R.id.img1);
   RelativeLayout.LayoutParams lParams = (RelativeLayout.LayoutParams)mImageView.getLayoutParams();
   lParams.width=50;
   lParams.height=70;
   mImageView.setLayoutParams(lParams);


9.动态获取控件的真实宽高
   int w = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);  
   int h = View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED);  
   mRadioButton1.measure(w, h);  
   int height =mRadioButton1.getMeasuredHeight();  
   int width =mRadioButton1.getMeasuredWidth();  

10.启动activity时不自动弹出软键盘

 getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);


11.ViewSwitcher的用法

ViewSwitcher 代表了视图切换组件, 本身继承了FrameLayout ,可以将多个View叠在一起 ,每次只显示一个组件.
当程序控制从一个View切换到另个View时,ViewSwitcher
支持指定动画效果.为了给ViewSwitcher 添加多个组件, 
一般通过ViewSwitcher 的setFactory 方法设置ViewFactory ,并由ViewFactory为之创建View 即可. 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值