【2013.07.03】界面布局

1.TextView中文字的行间距设置

android:lineSpacingExtra="8dp"

2.给TextView中的文字添加CSS样式

text.setText(Html.fromHtml("<font style='line-height:50px'>你好</div>"));

3.通过include包含进某个布局的局部布局,其中的控件也就相当于在当前的布局中,可在Java代码中通过findViewById直接获取

<include layout="@layout/common_header" />

4.checkbox的效果

<?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/cv_checked" /> <!-- checked -->
    <item android:state_checked="true" android:drawable="@drawable/cv_checked_not" /> <!-- default -->

</selector>

5.Button,点击背景改变后复原的效果

<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">

    <item android:drawable="@drawable/button_checked" android:state_pressed="true"/>
    <item android:drawable="@drawable/button_green_checkno" android:state_focused="false" android:state_pressed="false"/>

</selector>

6.ListView的监听

list.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int position,
					long arg3) {
				Toast.makeText(getApplicationContext(), ""+position, Toast.LENGTH_SHORT).show();

				
			}
		});

相关推荐