如何获取标题栏和状态栏高度
1.获取状态栏高度:
decorView是window中的最顶层view,可以从window中获取到decorView,然后decorView有个getWindowVisibleDisplayFrame方法可以获取到程序显示的区域,包括标题栏,但不包括状态栏。
于是可以算出状态栏的高度了。
Rect frame = new Rect();
getWindow().getDecorView().getWindowVisibleDisplayFrame(frame);
int statusBarHeight = frame.top;
2.获取标题栏高度:
getWindow().findViewById(Window.ID_ANDROID_CONTENT)这个方法获取到的view就是程序不包括标题栏的部分,然后就可以知道标题栏的高度了。
int contentTop = getWindow().findViewById(Window.ID_ANDROID_CONTENT).getTop();
//statusBarHeight是上面所求的状态栏的高度
int titleBarHeight = contentTop - statusBarHeight;
---------------------------------------------------------------------------------------------
让EditTextView 不能输入的方法
etNearbySearch.setFilters(new InputFilter[] { new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
}
} });
---------------------------------------------------------------------------------------------
全屏问题,在程序一加载的时候就让它是全屏
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
AndroidManifest.xml中这样写
<activity android:name=".TextButtonActivity" android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
---------------------------------------------------------------------------------------------
设置控件是否显示的属性设置
android 属性android:visibility
此属性意思是此视图是否显示,例如RelativeLayout中android:visibility="gone"
其有三个属性:visible显示;invisible显示黑背景条;gone不显示
在类中,可以设置其显示与否,setVisibility(View.GONE);不显示
setVisibility(View.VISIBLE);显示
---------------------------------------------------------------------------------------------
为了避免软键盘挡上输入框,可以试试设置
<activity android:windowSoftInputMode="stateVisible|adjustResize" >或者
<activity android:windowSoftInputMode="stateVisible|adjustPan" >
---------------------------------------------------------------------------------------------
设置控件的宽高,用setlayoutparams()方法
---------------------------------------------------------------------------------------------
做应用时,可能会需要动态改变控件的背景图片,如果仅仅是简单的点击,选中之类的事件,如果靠程序中写监听的代码就显得太麻烦了,在这种情况下,你可以使用selector动态改变控件背景
1、在res/drawable目录下建一个handlebackground.xml文件,根据需要,不同的状态下建立不同的item,并对应相应的图片
<?xml version="1.0" encoding="UTF-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/pressed_application_background_static" />
<item android:state_focused="true" android:state_enabled="true"
android:state_window_focused="true"
android:drawable="@drawable/focused_application_background_static" />
<item
android:drawable="@android:color/transparent" />
</selector>
2、在构造layout是引用这个xml
<ImageButton
android:id="@+id/imagebutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/normalbackground"
android:background="@drawable/handlebackground">
</ImageButton>
normalbackground.png 为你要显示的前景图片
pressed_application_background_static.png 为点击时的背景(系统默认为淡黄色)
focused_application_background_static.png 为焦点停留时的背景 (系统默认为橙色)
---------------------------------------------------------------------------------------------
取得androidsdk的版本,并设置动画效果
int version = Integer.valueOf(android.os.Build.VERSION.SDK);
if (version >= 5 ) {
overridePendingTransition(R.anim.zoomin, R.anim.zoomout); //此为自定义的动画效果,下面两个为系统的
两个自定义的动画效果XML文件,存放位置为:res/anim/
1,动画进入效果:zoomin.xml<?xml version= "1.0" encoding= "utf-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator" >
<scale android:fromXScale="2.0" android:toXScale= "1.0"
android:fromYScale="2.0" android:toYScale= "1.0"
android:pivotX="50%p" android:pivotY= "50%p"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
复制代码2,动画退出效果:zoomout.xml<?xml version= "1.0" encoding= "utf-8" ?>
<set xmlns:android="http://schemas.android.com/apk/res/android"
android:interpolator="@android:anim/decelerate_interpolator"
android:zAdjustment="top" >
<scale android:fromXScale="1.0" android:toXScale= ".5"
android:fromYScale="1.0" android:toYScale= ".5"
android:pivotX="50%p" android:pivotY= "50%p"
android:duration="@android:integer/config_mediumAnimTime" />
<alpha android:fromAlpha="1.0" android:toAlpha= "0"
android:duration="@android:integer/config_mediumAnimTime" />
</set>
---------------------------------------------------------------------------------------------
获得控件在屏幕或窗口内的坐标
int[] location = new int[2] ;
view.getLocationInWindow(location); //获取在当前窗口内的绝对坐标
view.getLocationOnScreen(location);//获取在整个屏幕内的绝对坐标
location [0]--->x坐标,location [1]--->y坐标
---------------------------------------------------------------------------------------------
控件对齐那点事
android:gravity 属性是对该view 内容的限定.比如一个button 上面的text. 你可以设置该text 在view的靠左,靠右等位置.该属性就干了这个.
android:layout_gravity是用来设置该view相对与起父view 的位置.比如一个button 在linearlayout里,你想把该button放在靠左 靠右等位置就可以通过该属性设置.
---------------------------------------------------------------------------------------------
几种Menu的使用说明
1.Options Menu.
通过按下手机上的MENU键,可以打开Options Menu。Options Menu最多只能在屏幕最下面显示6个菜单项,称为Icon Menu.如果添加了多于6个的菜单项,将通过"More"菜单项显示,这种称为Expanded Menu.当Options Menu第一次被打开时,系统将调用Activity的onCreateOptionsMenu(Menu menu)方法,在这个方法中可以通过配置一个XML文件,或者调用Menu的add()方法来添加你想要的Menu。Menu的add()方法将返回一个MenuItem对象,你用通过这个对象来配置一些其他属性。比如:icon,shortcut,intent。Menu的add()方法很多,要注意的是itemId这个参数,它的唯一性。
当选择了一个Options Menu时,会调用onOptionsItemSelected(MenuItem item)方法。如果想修改Options Menu,需要重写onPrepareOptionsMenu()方法。
方式一,用add()添加:
/* Creates the menu items */
public boolean onCreateOptionsMenu(Menu menu) {
menu.add(0, MENU_NEW_GAME, 0, "New Game");
menu.add(0, MENU_QUIT, 0, "Quit").setIcon(R.drawable.menu_quit_icon);
return true;
}
/* Handles item selections */
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case MENU_NEW_GAME:
newGame();
return true;
case MENU_QUIT:
quit();
return true;
}
return false;
}
方式二,通过XML文件添加:
在res/menu/下新建options_menu.xml文件:
Xml代码
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/new_game"
android:title="New Game" />
<item android:id="@+id/quit"
android:title="Quit" />
</menu>
在onCreateOptionsMenu()方法中,我们这样写:
Java代码
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.options_menu, menu);
return true;
}
2.Context Menu.
它需要注册到某个View对象上,当长按这个View大概2秒时间,会出现这个Context Menu。为某个View注册Context Menu是用registerForContextMenu(View view)方法来实现。Context Menu在显示前都会调用onCreateContextMenu来生成menu。onContextItemSelected用来处理选中的菜单项。
注意:Context Menu不支持icons和shortcut keys.
Java代码
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
menu.add(0, EDIT_ID, 0, "Edit");
menu.add(0, DELETE_ID, 0, "Delete");
}
public boolean onContextItemSelected(MenuItem item) {
AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
switch (item.getItemId()) {
case EDIT_ID:
editNote(info.id);
return true;
case DELETE_ID:
deleteNote(info.id);
return true;
default:
return super.onContextItemSelected(item);
}
}
注册这个Context Menu:
registerForContextMenu(getListView());
这里的 getListView()是ListActivity的方法,它将返回一个ListView.记住任何一个View对象都可以注册一个Context Menu。
3.Submenus
public boolean onCreateOptionsMenu(Menu menu) {
boolean result = super.onCreateOptionsMenu(menu);
SubMenu fileMenu = menu.addSubMenu("File");
SubMenu editMenu = menu.addSubMenu("Edit");
fileMenu.add(0,NEW_ID,0,"new");
fileMenu.add(0,OPEN_ID,0,"open");
fileMenu.add(0,SAV_ID,0,"save");
editMenu.add(0,UNDO_ID,0,"undo");
editMenu.add(0,REDO_ID,0,"redo");
return result;
}
4.Menu Features
Menu groups 菜单项分组的功能:
在用Menu的add()方法时,通过参数groupId的设置可以实现分组。setGroupVisible()用来显示或者隐藏你的菜单组。setGroupEnabled()用来启用或者禁用你的菜单组。setGroupCheckable()用来设置你的菜单项是否可选。 setGroupCheckable()方法有三个参数int group, boolean checkable, boolean exclusive。第一个参数是要设置的组,第二个参数是否可选,第三个参数为true表示单选,false表示多选。
Shortcut keys 快捷键:
我们还可以设置快捷键。使用setAlphabeticShortcut(char),setNumericShortcut(int),setShortcut(char,int)可以设置字符,数字,组合(字符+数字)键。注意:Context Menu不能添加快捷键。
---------------------------------------------------------------------------------------------
点击查看活动规则TextView及其子类,当字符内容太长显示不下时可以省略号代替未显示的字符;省略号可以在显示区域的起始,中间,结束位置,或者以跑马灯的方式显示文字(textview的状态为被选中)。
其实现只需在xml中对textview的ellipsize属性做相应的设置即可。
android:ellipsize="start" 省略号在开头
android:ellipsize="middle" 省略号在中间
android:ellipsize="end" 省略号在结尾
android:ellipsize="marquee" 跑马灯显示
---------------------------------------------------------------------------------------------
设置RadioButton的前面的图片,可定制的呵呵
<RadioGroup
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:checkedButton="@+id/lunch"
android:id="@+id/menu">
<RadioButton
android:text="@string/radio_group_1_breakfast"
android:id="@+id/breakfast"
android:button="@null"//自己找一个图片就可以
/>
RadioButton是可以自己定义button的显示的,我给的例子就不显示button
---------------------------------------------------------------------------------------------
android listview的分割线可以改变颜色
<ListView
android:id="@+id/android:list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:divider="#FFCC00"
android:dividerHeight="4px"/>
---------------------------------------------------------------------------------------------
保持屏幕唤醒状态
方法 1: use PowerManager and WakeLockAndroidManifest.xml权限:
<uses-permission android:name="android.permission.WAKE_LOCK" />
程序中的代码:
PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, "My Tag");
// in onResume() call
mWakeLock.acquire();
...
// in onPause() call
mWakeLock.release();
方法 2: use the window flag FLAG_KEEP_SCREEN_ON把下面的代码加入到程序onCreate方法中:
@Override
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Set keep screen on
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
---------------------------------------------------------------------------------------------
提醒用户输入有问题
直接上代码
Animation animation = AnimationUtils.loadAnimation(this, R.anim.shake);
EditText editText = (EditText) findViewById(R.id.edittext);
editText.startAnimation(animation);
里面面的fromXDelta,toXDelta是表示x轴方向的移动距离
shake.xml:
<translate xmlns:android="http://schemas.android.com/apk/res/android"
android:fromXDelta="0" android:toXDelta="30" android:duration="1000"
android:interpolator="@anim/cycle_interpolator" />
cycleInterpolator.xml文件:
<cycleInterpolator xmlns:android="http://schemas.android.com/apk/res/android"
android:cycles="3" />
抖动3次
---------------------------------------------------------------------------------------------
TextView 动态设置背景色
et.setBackgroundResource(R.color.white);
---------------------------------------------------------------------------------------------
防止ListView滚动的时候背景闪烁,需加上android:cacheColorHint="#00000000"
如果设置了listview的android:background="@drawable/background"
就要加上android:cacheColorHint="#00000000"
---------------------------------------------------------------------------------------------
通过添加一个id为android:empty的TextView,当ListView里面没有data的时候,就会显示TextView的内容。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ListView android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@id/android:empty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="对不起,没有数据显示"/>
</LinearLayout>
需要注意的是,ListView的id,使用的是"@id/android:list",即系统默认的id,而紧接其后的TextView,使用的id也是系统默认的,即"@id/android:empty"。
---------------------------------------------------------------------------------------------
自定义控件单行文本跑马灯控件
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.os.Parcel;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.Display;
import android.view.View;
import android.view.WindowManager;
import android.view.View.OnClickListener;
import android.widget.TextView;
/** *//**
*
* TODO 单行文本跑马灯控件
*
* @author tianlu
* @version 1.0
* Create At : 20##-2-16 下午09:35:03
*/
public class AutoScrollTextView extends TextView implements OnClickListener {
public final static String TAG = AutoScrollTextView.class.getSimpleName();
private float textLength = 0f;//文本长度
private float viewWidth = 0f;
private float step = 0f;//文字的横坐标
private float y = 0f;//文字的纵坐标
private float temp_view_plus_text_length = 0.0f;//用于计算的临时变量
private float temp_view_plus_two_text_length = 0.0f;//用于计算的临时变量
public boolean isStarting = false;//是否开始滚动
private Paint paint = null;//绘图样式
private String text = "";//文本内容
public AutoScrollTextView(Context context) {
super(context);
initView();
}
public AutoScrollTextView(Context context, AttributeSet attrs) {
super(context, attrs);
initView();
}
public AutoScrollTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initView();
}
/** *//**
* 初始化控件
*/
private void initView()
{
setOnClickListener(this);
}
/** *//**
* 文本初始化,每次更改文本内容或者文本效果等之后都需要重新初始化一下
*/
public void init(WindowManager windowManager)
{
paint = getPaint();
text = getText().toString();
textLength = paint.measureText(text);
viewWidth = getWidth();
if(viewWidth == 0)
{
if(windowManager != null)
{
Display display = windowManager.getDefaultDisplay();
viewWidth = display.getWidth();
}
}
step = textLength;
temp_view_plus_text_length = viewWidth + textLength;
temp_view_plus_two_text_length = viewWidth + textLength * 2;
y = getTextSize() + getPaddingTop();
}
@Override
public Parcelable onSaveInstanceState()
{
Parcelable superState = super.onSaveInstanceState();
SavedState ss = new SavedState(superState);
ss.step = step;
ss.isStarting = isStarting;
return ss;
}
@Override
public void onRestoreInstanceState(Parcelable state)
{
if (!(state instanceof SavedState)) {
super.onRestoreInstanceState(state);
return;
}
SavedState ss = (SavedState)state;
super.onRestoreInstanceState(ss.getSuperState());
step = ss.step;
isStarting = ss.isStarting;
}
public static class SavedState extends BaseSavedState {
public boolean isStarting = false;
public float step = 0.0f;
SavedState(Parcelable superState) {
super(superState);
}
@Override
public void writeToParcel(Parcel out, int flags) {
super.writeToParcel(out, flags);
out.writeBooleanArray(new boolean[]{isStarting});
out.writeFloat(step);
}
public static final Parcelable.Creator<SavedState> CREATOR
= new Parcelable.Creator<SavedState>() {
public SavedState[] newArray(int size) {
return new SavedState[size];
}
@Override
public SavedState createFromParcel(Parcel in) {
return new SavedState(in);
}
};
private SavedState(Parcel in) {
super(in);
boolean[] b = null;
in.readBooleanArray(b);
if(b != null && b.length > 0)
isStarting = b[0];
step = in.readFloat();
}
}
/** *//**
* 开始滚动
*/
public void startScroll()
{
isStarting = true;
invalidate();
}
/** *//**
* 停止滚动
*/
public void stopScroll()
{
isStarting = false;
invalidate();
}
@Override
public void onDraw(Canvas canvas) {
canvas.drawText(text, temp_view_plus_text_length - step, y, paint);
if(!isStarting)
{
return;
}
step += 0.5;
if(step > temp_view_plus_two_text_length)
step = textLength;
invalidate();
}
@Override
public void onClick(View v) {
if(isStarting)
stopScroll();
else
startScroll();
}
}
实现了宽度的判断,文本自动滚动及开始和停止滚动等功能。
在UI xml中的配置 如下:
<cn.tigertian.ui.AutoScrollTextView android:id="@+id/TextViewNotice"
android:layout_height="30px" android:layout_width="fill_parent"
android:text="@string/test_notice_1" android:textColor="#000" android:inputType="text"
android:background="#EEE" android:textSize="20px"></cn.tigertian.ui.AutoScrollTextView>
在Activity中的使用方法如下:
//启动公告滚动条
autoScrollTextView = (AutoScrollTextView)findViewById(R.id.TextViewNotice);
autoScrollTextView.init(getWindowManager());
autoScrollTextView.startScroll();
如果想改变跑马灯的文字内容或者文字效果,则在调用完setText方法之后,需要再调用一下init(WindowManager windowManager)方法,重新进行初始化和相关参数的计算。
---------------------------------------------------------------------------------------------
大概意思是。@和?都是用来引用其他已经定义好的资源的。@引用的是之前定义好的资源当前项目或者android的framework里。而?则是引用的当前加载的样式文件里。意思就是说你在xml里某行定义了一个资源,在下面某行需要引用这个资源时用?即可
---------------------------------------------------------------------------------------------
TabHost两种实现方式
文章分类:Java编程
第一种:继承TabActivity,从TabActivity中用getTabHost()方法获取TabHost。只要定义具体Tab内容布局就行了.
xml布局:
Java代码
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/widget_layout_Blue"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText android:id="@+id/widget34" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="EditText"
android:textSize="18sp">
</EditText>
<Button android:id="@+id/widget30" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Button">
</Button>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_red"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >
<AnalogClock android:id="@+id/widget36"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</AnalogClock>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_green"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RadioGroup android:id="@+id/widget43"
android:layout_width="166px" android:layout_height="98px"
android:orientation="vertical">
<RadioButton android:id="@+id/widget44"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="RadioButton">
</RadioButton>
<RadioButton android:id="@+id/widget45"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="RadioButton">
</RadioButton>
</RadioGroup>
</LinearLayout>
</FrameLayout>
java代码:
super.onCreate(savedInstanceState);
myTabhost=this.getTabHost();
//get Tabhost
LayoutInflater.from(this).inflate(R.layout.main, myTabhost.getTabContentView(), true);
myTabhost.setBackgroundColor(Color.argb(150, 22, 70, 150));
myTabhost
.addTab(myTabhost.newTabSpec("One")// make a new Tab
.setIndicator("A")
// set the Title and Icon
.setContent(R.id.widget_layout_Blue));
// set the layout
myTabhost
.addTab(myTabhost.newTabSpec("Two")// make a new Tab
.setIndicator("B",
getResources().getDrawable(R.drawable.mumule))
// set the Title and Icon
.setContent(R.id.widget_layout_green));
// set the layout
myTabhost
.addTab(myTabhost.newTabSpec("Three")// make a new Tab
.setIndicator("C",
getResources().getDrawable(R.drawable.notepad))
// set the Title and Icon
.setContent(R.id.widget_layout_red));
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<LinearLayout android:id="@+id/widget_layout_Blue"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >
<EditText android:id="@+id/widget34" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="EditText"
android:textSize="18sp">
</EditText>
<Button android:id="@+id/widget30" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="Button">
</Button>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_red"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" >
<AnalogClock android:id="@+id/widget36"
android:layout_width="wrap_content" android:layout_height="wrap_content">
</AnalogClock>
</LinearLayout>
<LinearLayout android:id="@+id/widget_layout_green"
android:layout_width="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical">
<RadioGroup android:id="@+id/widget43"
android:layout_width="166px" android:layout_height="98px"
android:orientation="vertical">
<RadioButton android:id="@+id/widget44"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="RadioButton">
</RadioButton>
<RadioButton android:id="@+id/widget45"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:text="RadioButton">
</RadioButton>
</RadioGroup>
</LinearLayout>
</FrameLayout>
java代码:
super.onCreate(savedInstanceState);
myTabhost=this.getTabHost();
//get Tabhost
LayoutInflater.from(this).inflate(R.layout.main, myTabhost.getTabContentView(), true);
myTabhost.setBackgroundColor(Color.argb(150, 22, 70, 150));
myTabhost
.addTab(myTabhost.newTabSpec("One")// make a new Tab
.setIndicator("A")
// set the Title and Icon
.setContent(R.id.widget_layout_Blue));
// set the layout
myTabhost
.addTab(myTabhost.newTabSpec("Two")// make a new Tab
.setIndicator("B",
getResources().getDrawable(R.drawable.mumule))
// set the Title and Icon
.setContent(R.id.widget_layout_green));
// set the layout
myTabhost
.addTab(myTabhost.newTabSpec("Three")// make a new Tab
.setIndicator("C",
getResources().getDrawable(R.drawable.notepad))
// set the Title and Icon
.setContent(R.id.widget_layout_red));
第二种:不用继承TabActivity,在布局文件中定义TabHost即可,但是TabWidget的id必须是
@android:id/tabs,FrameLayout的id必须是@android:id/tabcontent。TabHost的id可以自定义.
xml布局:
Java代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/hometabs"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabHost android:id="@+id/tabhost"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TabWidget android:id="@android:id/tabs"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</TabWidget>
<FrameLayout android:id="@android:id/tabcontent"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/view1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/view2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
<TextView android:id="@+id/view3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
java代码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.hometabs);
TabHost tabHost = (TabHost) findViewById(R.id.tabhost);
tabHost.setup();
TabWidget tabWidget = tabHost.getTabWidget();
tabHost.addTab(tabHost.newTabSpec("tab1")
.setIndicator("tab1", getResources().getDrawable(R.drawable.mumule))
.setContent(R.id.view1));
tabHost.addTab(tabHost.newTabSpec("tab3")
.setIndicator("tab3")
.setContent(R.id.view3));
tabHost.addTab(tabHost.newTabSpec("tab2")
.setIndicator("tab2")
.setContent(R.id.view2));
final int tabs = tabWidget.getChildCount();
Log.i(TAG, "***tabWidget.getChildCount() : " + tabs);
final int tabWidth = 90;
final int tabHeight = 45;
for (int i = 0; i < tabs; i++) {
/* final View view = tabWidget.getChildAt(i);
view.getLayoutParams().width = tabWidth;
view.getLayoutParams().height = tabHeight;
final TextView tv = (TextView) view.findViewById(android.R.id.title);
tv.setTextColor(this.getResources().getColorStateList(android.R.color.black));
MarginLayoutParams tvMLP = (MarginLayoutParams)tv.getLayoutParams();
tvMLP.bottomMargin = 8;*/
}
}
---------------------------------------------------------------------------------------------
TextView显示图片和文字
TextView text = (TextView) findViewById(R.id.TextView01);
Drawable draw = this.getResources().getDrawable(R.drawable.srvmng);
text.setCompoundDrawablesWithIntrinsicBounds(null, draw, null,null);
text.setText("应用");
---------------------------------------------------------------------------------------------
Android中我们为了实现文本的滚动可以在ScrollView中嵌入一个TextView,其实TextView自己也可以实现多行滚动的,毕竟ScrollView必须只能有一个直接的子类布局。只要在layout中简单设置几个属性就可以轻松实现
<TextView
android:id="@+id/tvCWJ"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" <!--垂直滚动条 -->
android:singleLine="false" <!--实现多行 -->
android:maxLines="15" <!--最多不超过15行 -->
android:textColor="#FF0000"
/>
当然我们为了让TextView动起来,还需要用到TextView的setMovementMethod方法设置一个滚动实例,代码如下
TextView tv = (TextView)findViewById(R.id.tvCWJ);
tv.setMovementMethod(ScrollingMovementMethod.getInstance());
---------------------------------------------------------------------------------------------
class DownloadJSONTask extends AsyncTask<String, Void, String>这样的类中
不要在doInBackground显示对话框,那个函数不会运行在UI线程上,试试在onPostExecute和onProgressUpdate显示
---------------------------------------------------------------------------------------------
控件点击后,链接到一个网址
ImageView img = (ImageView)findViewById(R.id.foo_bar);
img.setOnClickListener(new View.OnClickListener(){
public void onClick(View v){
Intent intent = new Intent();
intent.setAction(Intent.ACTION_VIEW);
intent.addCategory(Intent.CATEGORY_BROWSABLE);
intent.setData(Uri.parse("http://casidiablo.net"));
startActivity(intent);
}
});
---------------------------------------------------------------------------------------------
TextView里面文本设置加粗,底线等,使用html格式,文本颜色的设置
在xml文件里支持html格式,你可以用<b></b>, <i></i> 和 <u></u>.
<resource>
<string name="your_string_here">This is an <u>underline</u>.</string>
</resources><b></b>, <i></i> and <u></u>.
txtChange.setTextColor(0xE01B4C); 改成txtChange.setTextColor(0xffE01B4C); 就可以了
调用setTextColor()记得在前面加上0xff,然后再加上颜色值
---------------------------------------------------------------------------------------------
今晚有点时间把断了很长时间的UI开发补一下,这次实现的是像handcent sms或者chomp sms那样的气泡短信样式。
给代码:
(1)listview:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@android:color/white"
>
<ListView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@null"
android:dividerHeight="0dip"
android:cacheColorHint="#00000000"
android:listSelector="@drawable/list_item_style"
android:id="@+id/itemlist" />
</LinearLayout>
(2)ListView item
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/black"
android:background="@drawable/bg"></TextView>
</LinearLayout>
(3)java:
public class HandcentList extends Activity {
/** Called when the activity is first created. */
ListView itemlist = null;
List<Map<String, Object>> list;
final String[] str={"A","B","C","D","E","F"};
/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
itemlist = (ListView) findViewById(R.id.itemlist);
refreshListItems();
}
private void refreshListItems() {
list = buildListForSimpleAdapter();
SimpleAdapter notes = new SimpleAdapter(this, list, R.layout.item,
new String[] { "str" }, new int[] { R.id.TextView01,});
itemlist.setAdapter(notes);
itemlist.setSelection(0);
}
private List<Map<String, Object>> buildListForSimpleAdapter() {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(2);
// Build a map for the attributes
Map<String, Object> map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵\n呵呵呵呵\n呵呵\n呵呵");
list.add(map);
map = new HashMap<String, Object>();
map.put("str", "呵呵呵呵呵呵呵呵呵呵呵呵呵呵\n呵呵呵呵");
list.add(map);
return list;
}
}
---------------------------------------------------------------------------------------------
创建快捷方式
public static void addShortcut(Context context) {
String ACTION_INSTALL_SHORTCUT = "com.android.launcher.action.INSTALL_SHORTCUT";
// 快捷方式要启动的包
Intent intent = gotoWhere(context);
// 设置快捷方式的参数
Intent shortcutIntent = new Intent(ACTION_INSTALL_SHORTCUT);
// 设置名称
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, context.getResources()
.getString(R.string.wap)); // 设置启动 Intent
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, intent);
// 设置图标
shortcutIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE,
Intent.ShortcutIconResource.fromContext(context,
R.drawable.icon));
// 只创建一次快捷方式
shortcutIntent.putExtra("duplicate", false);
// 创建
context.sendBroadcast(shortcutIntent);
}
---------------------------------------------------------------------------------------------
我的经验是最内层用wrap_content实现非均等分割,外层用fill_parent
有人告诉我这么整:将子LinearLayout的android:layout_height="0dip"我试了,很好用。。
---------------------------------------------------------------------------------------------
通过程序挂断电话代码
iTelephony = (ITelephony) getITelephonyMethod.invoke(telMgr, (Object[])null);
iTelephony.endCall();
---------------------------------------------------------------------------------------------
Android 屏幕相关单位解释
dip: device independent pixels(设备独立像素). 不同设备有不同的显示效果,这个和设备硬件有关,一般我们为了支持WVGA、HVGA和QVGA 推荐使用这个,不依赖像素。
px: pixels(像素). 不同设备显示效果相同,一般我们HVGA代表320x480像素,这个用的比较多。
pt: point,是一个标准的长度单位,1pt=1/72英寸,用于印刷业,非常简单易用;
sp: scaled pixels(放大像素). 主要用于字体显示best for textsize。
---------------------------------------------------------------------------------------------
TextView 中可现实图片和文字混排效果
final TextView textView = (TextView)findViewById(R.id.diet_log_label);
final Drawable iconDrawable = getResources().getDrawable(R.drawable.icon);
textView.setCompoundDrawablesWithIntrinsicBounds(iconDrawable, iconDrawable, iconDrawable, iconDrawable);
---------------------------------------------------------------------------------------------
LinearLayout 使用Layout_weight 时所占比重与Layout_height所用的方式有关
LinearLayout内部的LinearLayout用fill_parent,layout_weight值越大占的空间越小,
LinearLayout内的控件用wrap_content,layout_weight值越大占的空间越大
---------------------------------------------------------------------------------------------
自定义控件一般指的自绘控件, 最简单的形式就是继承View,然后在onDraw方法里面使用Canvas画布进行绘制
其实最好是继承 ImageView TextView 等这样的已有组建,防止自定义组建影响布局
自定义控件主要覆盖两个方法onDraw和ontouch
今天尝试做个类似街霸中的游戏场景,头部需要显示PK双方的血条。
为了达到一个对称的效果,右边的血条要从左往右减少。
展现血条首先想到的是使用ProgressBar,但是发现都是从右往左减少。
google了下,没发现有资料介绍如何配置来实现从左到右变化的效果。
万幸的是,我们可以看到源码。那么自己动手,丰衣足食,
一、失败的尝试
首先想到的是使用Matrix来做镜像处理。
将ProgressBar中的源码copy出来,建一个自己的进度条MyProgressBar。
当然,这中间要处理很多错误信息。需要定义自己的进度条可配置的属性,样式等等。
修改ProgressBar中的onDraw方法:
1. [color=Red]
2. Matrix m = new Matrix();
3. m.setScale(-1,1);
4. m.postTranslate(d.getMinimumWidth() + getPaddingLeft(),getPaddingTop());
5. canvas.setMatrix(m);
6. [/color]
7. d.draw(canvas);
复制代码
红色部分为我添加的内容。跑起来后发现progressBar中存在MinWidth和MaxWidth,不同
情况下会影响布局。无奈下只能跟代码了。
二、成功的尝试
这次跟进了
1. d.draw(canvas);
复制代码
这行代码,发现progressBar在构造的时候使用了ClipDrawable. 阅读下文档发下如下介绍:
android:clipOrientation The orientation for the clip.
android:gravity Specifies where to clip within the drawable.
翻译过来就是:
android:clipOrientation 定义裁剪的方向(水平方向裁剪还是垂直方向裁剪)
android:gravity 指定drawable中可裁剪的部分
尝试修改了下progressBar的Drawable配置文件:
1. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
2. <item android:id="@android:id/background">
3. <shape>
4. <corners android:radius="5dip" />
5. <gradient
6. android:startColor="#ff9d9e9d"
7. android:centerColor="#ff5a5d5a"
8. android:centerY="0.75"
9. android:endColor="#ff747674"
10. android:angle="270"
11. />
12. </shape>
13. </item>
14.
15. <item android:id="@android:id/secondaryProgress">
16. [color=Red]
17. <clip android:gravity="right">
18. [/color]
19. <shape>
20. <corners android:radius="5dip" />
21. <gradient
22. android:startColor="#80ffd300"
23. android:centerColor="#80ffb600"
24. android:centerY="0.75"
25. android:endColor="#a0ffcb00"
26. android:angle="270"
27. />
28. </shape>
29. </clip>
30. </item>
31.
32. <item android:id="@android:id/progress">
33. [color=Red]
34. <clip android:gravity="right">
35. [/color]
36. <shape>
37. <corners android:radius="5dip" />
38. <gradient
39. android:startColor="#ffffd300"
40. android:centerColor="#ffffb600"
41. android:centerY="0.75"
42. android:endColor="#ffffcb00"
43. android:angle="270"
44. />
45. </shape>
46. </clip>
47. </item>
48. </layer-list>
复制代码
同时定义进度条的样式:
1. <?xml version="1.0" encoding="utf-8"?>
2. <resources>
3. <style name="myProgressBarStyle">
4. <item name="indeterminateOnly">false</item>
5. <item name="progressDrawable">@drawable/progress_horizental</item>
6. <item name="minHeight">12dip</item>
7. <item name="maxHeight">12dip</item>
8. <item name="minWidth">100dip</item>
9. <item name="maxWidth">150dip</item>
10. </style>
11. </resources>
复制代码
运行后的效果:
TabWidget控件的样式,是tab条在屏幕的下方,而内容部分在屏幕上方
TabHost是整个Tab的容器,包括两部分,TabWidget和FrameLayout。TabWidget就是每个tab的标签,FrameLayout则是tab内容。
1、如果我们使用extends TabAcitivty,如同ListActivity,TabHost必须设置为@android:id/tabhost
2、TabWidget必须设置android:id为@android:id/tabs
3、FrameLayout需要设置android:id为@android:id/tabcontent
4、参考这儿:http://blog.csdn.net/flowingflyi ... /04/06/6304289.aspx
先自定义一个xml文件:
1. <?xml version="1.0" encoding="utf-8"?>
2. <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
3. android:id="@android:id/tabhost"
4. android:layout_width="fill_parent"
5. android:layout_height="fill_parent">
6. <LinearLayout
7. android:orientation="vertical"
8. android:layout_width="fill_parent"
9. android:layout_height="fill_parent">
10. <FrameLayout
11. android:id="@android:id/tabcontent"
12. android:layout_width="fill_parent"
13. android:layout_height="fill_parent"
14. android:layout_weight="1.0"
15. android:paddingBottom="53px"/>
16. <TabWidget
17. android:id="@android:id/tabs"
18. android:layout_alignParentBottom="true"
19. android:layout_width="fill_parent"
20. android:layout_height="50px"
21. android:visibility="gone"
22. android:layout_weight="0.0"/>
23. <RadioGroup
24. android:gravity="center_vertical"
25. android:orientation="horizontal"
26. android:id="@+id/main_radio"
27. android:background="@drawable/radiogroup_background"
28. android:layout_width="fill_parent"
29. android:layout_height="50dip"
30. android:layout_gravity="bottom">
31. <RadioButton
32. android:id="@+id/main_index_button"
33. android:layout_marginTop="1.0dip"
34. android:layout_marginRight="5dip"
35. android:text="@string/main_name"
36. android:drawableTop="@drawable/unistall"
37. style="@style/main_tab_bottom"
38. android:background="@drawable/radio_bg"/>
39. <RadioButton
40. android:id="@+id/main_running_button"
41. android:layout_marginTop="1.0dip"
42. android:layout_marginRight="5dip"
43. android:text="@string/run_manager_name"
44. android:drawableTop="@drawable/unistall"
45. style="@style/main_tab_bottom"
46. android:background="@drawable/radio_bg"/>
47. <RadioButton
48. android:id="@+id/main_uninstall_button"
49. android:layout_marginTop="1.0dip"
50. android:text="@string/uninstall_manager_name"
51. android:drawableTop="@drawable/unistall"
52. style="@style/main_tab_bottom"
53. android:background="@drawable/radio_bg"/>
54. </RadioGroup>
55. </LinearLayout>
56. </TabHost>
复制代码
为了让tabHost显示在下方,要将RadioGroup的layout_gravity设置为bottom,再将FrameLayout的layout_weight设置为1,这样就可以将RadioGroup撑到最下方。style="@style/main_tab_bottom"里面定义了样式文件。
接下来就是在activity中初始化并添加tabhost:
1. tabHost = (TabHost) findViewById(android.R.id.tabhost);
2. tabHost.addTab(Constant.tabHost.newTabSpec("Main")
3. .setIndicator(getString(R.string.main_name),null)
4. .setContent(new Intent(this, Main.class)));
5. tabHost.addTab(Constant.tabHost.newTabSpec("RunManager")
6. .setIndicator(getString(R.string.run_manager_name),null)
7. .setContent(new Intent(this, RunManager.class)));
8. tabHost.addTab(Constant.tabHost.newTabSpec("UninstallManager")
9. .setIndicator(getString(R.string.uninstall_manager_name),null)
10. .setContent(new Intent(this, UninstallManager.class)));
复制代码
初始化每个RadioButton并为其添加setOnCheckedChangeListener事件,当点击相应的RadioButton时就可以通过setCurrentTabByTag()方法显示到当前页面。
1. private void initRadios() {
2. ((RadioButton) findViewById(R.id.main_index_button))
3. .setOnCheckedChangeListener(this);
4. ((RadioButton) findViewById(R.id.main_running_button))
5. .setOnCheckedChangeListener(this);
6. ((RadioButton) findViewById(R.id.main_uninstall_button))
7. .setOnCheckedChangeListener(this);
8. }
9.
10. @Override
11. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
12. if(isChecked){
13. switch (buttonView.getId()) {
14. case R.id.main_index_button:
15. tabHost.setCurrentTabByTag("Main");
16. break;
17. case R.id.main_running_button:
18. tabHost.setCurrentTabByTag("RunManager");
19. break;
20. case R.id.main_uninstall_button:
21. tabHost.setCurrentTabByTag("UninstallManager");
22. break;
23. }
24. }
25. }
---------------------------------------------------------------------------------------------
在OnClickListener 等Listener 事件中,可以根据
View.getId()方法来判断是哪个控件被选中了
---------------------------------------------------------------------------------------------
Dialog 去掉边白方法
使用样式文件,在values 目录下新建styles.xml文件,编写如下代码:
<resources>
<style name="dialog" parent="@android:style/Theme.Dialog">
<item name="android:windowFrame">@null</item>
<item name="android:windowIsFloating">true</item>
<item name="android:windowIsTranslucent">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:background">@android:color/black</item>
<item name="android:windowBackground">@null</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
</resources>
调用时,使用AlerDialog的接口类,Dialog 接口编写如下代码:
Dialog dialog = new Dialog(SetActivity.this, R.style.dialog);
dialog.setContentView(R.layout.test);
dialog.show();
下面我们查看一下Dialog的源码文件,里面的构造函数为如下:
public Dialog(Context context, int theme) {
mContext = new ContextThemeWrapper(
context, theme == 0 ? com.android.internal.R.style.Theme_Dialog : theme);
mWindowManager = (WindowManager)context.getSystemService("window");
Window w = PolicyManager.makeNewWindow(mContext);
mWindow = w;
w.setCallback(this);
w.setWindowManager(mWindowManager, null, null);
w.setGravity(Gravity.CENTER);
mUiThread = Thread.currentThread();
mDismissCancelHandler = new DismissCancelHandler(this);
}
这里面我们可以看出,Android 使用了默认的构造函数为Dialog 设置样式,如果没有为其设置样式,即默认加载事先编写好的样式文件,Dialog 一共由多个9.png的图片构成,大部分都是带有边框的9.png图片,所以就是为什么我们上边的样式文件要将其背景去除掉。这个东西搞了我好久,希望对你有帮助
前后效果对比
未设置前:
设置后:
---------------------------------------------------------------------------------------------
Android 取得手机3G上网的IP
public String getLocalIpAddress() {
try {
for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) {
NetworkInterface intf = en.nextElement();
For (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) {
InetAddress inetAddress = enumIpAddr.nextElement();
if (!inetAddress.isLoopbackAddress()) {
return inetAddress.getHostAddress().toString();
}
}
}
} catch (SocketException ex) {
Log.e(LOG_TAG, ex.toString());
}
return null;
}
EditText在代码中让用户输入无效
editLicenseNo.setFilters(new InputFilter[] { new InputFilter() {
@Override
public CharSequence filter(CharSequence source, int start,
int end, Spanned dest, int dstart, int dend) {
return source.length() < 1 ? dest.subSequence(dstart, dend) : "";
}
} });
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------
如何获取标题栏和状态栏高度1获取状态栏高度decorView是window中的最顶层view可以从window中获取到decorV…
一android四大组件ActivityServiceBroadcastReceiverContentProvider二Activ…
项目目录结构Srcjavaclass源文件GenAndroid开发工具自动生成自动维护不能修改Rjava不能手工修改此类中的内容记…
Android手机游戏知识点总结Android手机游戏开发学习笔记第一部分其实游戏就是让状态机不断的让Canvas在View上画你…
目录Android知识点3一dom解析以及写入数据到xml文件3二连接socket并获取返回值4三创建socket服务器4四获取本…
个人总结我于20xx年x月x日进入公司,根据公司的需要,目前担任Android软件工程师一职,负责综合代维,考务通手机客户端的开发…
光阴如梭,眨眼之间学期又近结束。从成立之初到现在,Android创新团队也已经走过了半年的时光。回首这个学期的团队工作,感到忙碌而…
1概述实习是一种实践,是理论联系实际,应用和巩固所学专业知识的一项重要环节,是培养我们能力和技能的一个重要手段。在本学期的期末假期…
《Android应用开发》个人总结报告一、项目简介:送祝福App是一款逢年过节为方便发送祝福信息的软件,并且介绍各种节日的相关情况…
零零碎碎的总结(该文章本人第一更新是在优亿论坛):1.客户端的功能逻辑不难,UI界面也不难,但写UI花的时间是写功能逻辑的两倍.2…
一android四大组件ActivityServiceBroadcastReceiverContentProvider二Activ…