PreferenceCategory 这是在应用设置里面的一个控件?如何设置android 分割线颜色的颜色啊?

随笔- 169&
评论- 781&
  StatusStrip控件用于在WinForm中显示窗体的状态信息,及DataGridView表格的信息等,如显示当前选中的行或列数,总记录数等。该控件默认出现在窗体的最下面,当然如果需要你也可以通过修改控件的Dock属性将它放置在窗体的其它位置。看下面的截图,如何在StatusStrip控件中设置分割线及将部分子控件显示在右边?
  首先来看如何设置分割线。这个很简单,在StatusStrip中添加一个StatusLabel类型的子项,将BorderSides改成Left或Right即可。
  有的时候我们希望在StatusStrip中加入一个Label或ProgressBar并且想让它们显示在最右边,怎么办呢?StatusStrip中没有单独设置某个子项左对齐或右对齐的属性,这时我们可以在需要右对齐的子项之前添加一个空白的Label类型的子项,并将它的Spring属性设置为True,之后的子项将自动跑到最右边了。ToolStripStatusLabel的Spring属性用于指示该控件是否占满StatusStrip的所有剩余空间,就像一个弹簧一样。是不是很简单啊?
阅读(...) 评论()Android开发之精仿QQ设置界面(自定义PreferenceActivity)
今天,再给大家分享一下QQ设置界面的UI布局实现,不罗嗦,直接上图
设置主界面
皮肤设置界面
流量统计界面
好友设置界面(其实这个不在设置界面里,工程里有该ACTIVITY,就在最后加上了)
在开发应用程序的过程中我们有很大的机会需要用到参数设置功能
那么在Android应用中,我们如何实现参数设置界面及参数存储呢
答案是使用PreferenceActivity,相信大家并不陌生
只不过系统自带的样式黑布隆冬的,看起来很不美观,难登大雅之堂
只要我们稍加修饰,便可扭转乾坤,化别扭为和谐
主要是在MainFeast配置文件里给ACTIVITY加上自定义的样式&
&&&&&&& &activity android:name=&.SettingActivity&
&&&&&&&&&&&&&&&&& android:label=&设置与帮助&
&&&&&&&&&&&&&&&&& android:theme=&@style/Default&
&&&&&&&&&&&&&&&&& android:configChanges=&keyboardHidden|orientation& &
&&&&&&&&&&& &intent-filter&
&&&&&&&&&&&&&&& &action android:name=&android.intent.action.MAIN& /&
&&&&&&&&&&&&&&& &category android:name=&android.intent.category.LAUNCHER& /&
&&&&&&&&&&& &/intent-filter&
&&&&&&& &/activity&
且看 Style.xml配置文件
&?xml version=&1.0& encoding=&utf-8&?&
&resources&
&&&&&&& &style name=&CustomWindowTitleBackground&&
&&&&&&& &item name=&android:background&&@drawable/skinpic_green&/item&
&&& &/style&
&&&& &style name=&CustomWindowTitleText& &&
&&&&&&&&& &item name=&android:textSize&&20dip&/item&&
&&&&&&&&& &item name=&android:textColor&&#FFffffff&/item&&
&&&&&&&&& &item name=&android:paddingLeft&&10dp&/item&
&&&& &/style&
&&& &style name=&customCheckBox& parent=&@android:poundButton.CheckBox&&
&&&&&&& &item name=&android:button&&@drawable/selector_checkbox&/item&
&&& &/style&
&&& &style name=&customListView& parent=&@android:style/Widget.ListView&&
&&&&&&& &item name=&android:scrollbarSize&&10.0dip&/item&
&&&&&&& &item name=&android:scrollbarThumbVertical&&@drawable/scrollbar_handle_vertical&/item&
&&&&&&& &item name=&android:listSelector&&@drawable/selector_list&/item&
&&&&&&& &item name=&android:cacheColorHint&&#&/item&
&&& &/style&
&&& &style name=&Default.NoTitleBar& parent=&@android:style/Theme.Light.NoTitleBar&&
&&&&&&&&&&&&&&& &item name=&android:textColorPrimaryInverse&&@android:color/black&/item&&&&&&&&&&&
&&&&&&& &item name=&android:windowBackground&&@color/window_bg&/item&
&&&&&&& &item name=&android:windowContentOverlay&&@null&/item&
&&&&&&& &item name=&android:windowTitleSize&&42.0dip&/item&
&&&&&&& &item name=&android:windowTitleStyle&&@style/CustomWindowTitleText&/item&
&&&&&&& &item name=&android:windowTitleBackgroundStyle&&@style/CustomWindowTitleBackground&/item&
&&&&&&& &item name=&android:checkboxStyle&&@style/customCheckBox&/item&
&&&&&&& &item name=&android:listViewStyle&&@style/customListView&/item&
&&& &/style&
&&& &style name=&Default& parent=&@style/Default.NoTitleBar&&
&&&&&&& &item name=&android:windowNoTitle&&false&/item&
&&& &/style&
&/resources&
本例只用到了CheckBox和ListView,如果大家的设置界面有用到其它控件
如editText,radioButton之类的,只需依葫芦画瓢,加上editTextStyle,radioButtonStyle即可
如需自定义Preference布局,则需派生一个Preference子类,并配置相关XML布局文件
详情请见:http://blog.csdn.net/aomandeshangxiao/article/details/6659346
在此就不多言了
像好友资料这样的UI布局还是很常见的,很多人可能不知道怎么实现
主要是采用了线形布局,一个白框是个linearlayout,白框内一行行的同样是linearlayout
分割线则是采用了shape的配置布局
&?xml version=&1.0& encoding=&UTF-8&?&
&shape android:shape=&rectangle&
& xmlns:android=&&&
&&& &solid android:color=&#ffe0e0e0& /&
当然类似布局的实现未必都是如此,这里只是给大家提供一个思路
好了其它的也不多说了,自己下工程看吧
最新开班信息
Android课程
免费咨询热线
400-654-7778
免费咨询热线
400-648-7779
免费咨询热线
400-654-7774
千锋教育微信号扫描加好友
北京天丰利校区:北京市海淀区宝盛北里西区28号天丰利商城4层
咨询电话:400-654-
北京沙河校区:北京市昌平区沙阳路18号北京科技职业技术学院广场服务楼2层、南区服务楼2层
深圳科技园校区:广东省深圳市南山区高新技术产业园R3栋B5楼
咨询电话:400-648--801
深圳大学城校区:深圳市南山区留仙大道1201号大学城创客小镇16栋3楼 咨询电话:400-648--801
上海学院地址:上海市宝山区同济支路199号智慧七立方3号楼2-4层
咨询电话:400-654-
郑州学院地址:郑州市金水区纬五路21号河南教育学院综合楼6楼、7楼 咨询电话:0 7
广州学院地址:广州市天河区元岗路310号智汇park创意园E座5层
咨询电话:400-654-19207
大连学院地址:大连市高新园区软件园路18号软件园9号楼105室
咨询电话:400-654-026086
武汉学院地址:武汉市东新区光谷大道77号金融港B26栋9楼
咨询电话:400-654-
成都学院地址:成都市一环路西二段17号四川旅游学院青羊校区内
咨询电话:028--
西安学院地址:西安市二环南路西段60号永安大厦4层
咨询电话:400-654-
京ICP备号-3 京公网安备55号Material Design 风格的设置页面 | Drakeet的个人博客
最近访客打赏
如果你觉得我的文章很好的话,请帮忙分享转发给你的朋友们,或者打赏我一小杯咖啡的钱,无论是分享 or 打赏,都将是我不懈的动力,非常感谢!如若能因此有点小收入,我也很愿意不断地认真地写更多更好的文章:)
统计累积访问量:358067
&&&&&&&&&&&&-- 统计自
欢迎并且感谢你的到来^ ^下次自动登录
现在的位置:
& 综合 & 正文
android 表格控件
android 没有现成的表格控件,但我们可以根据Tablayout,ListView等组合出自己的表格。废话少说,使用Tablayout自己写一个表格控件,该表格控件可以自己设置表头,动态的添加行,自定义背景颜色等。
首先表格的的的某一项的文字可能很多,也可能是表格中有大的图片等内容,因此可能一个屏幕不够用的情况,这是必须使用水平和垂直的滚动条了,既然表格中不仅仅有文字,因此必须自己写好表格的每一行即是TabRow
import android.content.C
import android.graphics.C
import android.util.AttributeS
import android.widget.HorizontalScrollV
import android.widget.ScrollV
import android.widget.TableL
import android.widget.TableR
* 一个表格控件
public class KtableView extends ScrollView {
private TableLayout tableL //表格布局
private AddDivisionRow divisionR
//水平分割线
//各种参数
private int headColor = Color.WHITE;
private int headHeight = TableRow.LayoutParams.WRAP_CONTENT;
private int headtextColor = Color.BLACK;
private int hedaMaxEms = 10;
private int divisonColor = Color.RED;
private int divisonWidth = 1;
private int resId = 0;
private int backgroudColor = Color.WHITE;
private int cellMaxEms = 10;;
private int cellTextColor = Color.BLACK;
private int cellTextSize = 15;
private int cellHeight = TableRow.LayoutParams.WRAP_CONTENT;
public KtableView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
initWidge();
* 公共接口
* 设置表格的标题头
public void setTableHeaders(String[] header){
//添加分割线
divisionRow = new AddDivisionRow(getContext());
tableLayout.addView(divisionRow.addTableRow());
AddHeadRow
row = new AddHeadRow(getContext(), header);
row.setDivisonColor(divisonColor);
row.setDivisonWidth(divisonWidth);
row.setBackgroundColor(headColor);
row.setTabRowHeight(headHeight);
row.setTextMaxEms(hedaMaxEms);
row.setTextClor(headtextColor);
tableLayout.addView(row.addTableRow());
tableLayout.addView(divisionRow.addTableRow()); //添加分割线
* 设置表格头的背景颜色
public void setTableheadColor(int color){
this.headColor =
* 设置表头的的高度
public void setTableHeadHeigt(int height){
this.headHeight =
* 设置表头的的字体颜色
public void setTableHeadTextcolor(int color){
this.headtextColor =
* 设置表头的的字体大小
public void setTableHeadMaxEms(int size){
this.hedaMaxEms =
public void setTableDivisonColor(int color){
this.divisonColor =
public void setTableDivisonWidth(int width){
this.divisonWidth =
/*******************内容
**************/
* 添加新的一行,目前的版本仅支持表格中由图像的下信息
* @@param objects
* 添加的内容
* @@param columns
* 表格的哪一行为图片数据
public void
addNewRow(Object[] objects,int[] columns){
AddContentsRow addContentsRow = new AddContentsRow(getContext(), objects, columns);
if(resId != 0)
addContentsRow.setBackground(resId);
addContentsRow.setBackColor(backgroudColor);
addContentsRow.setTextColor(cellTextColor);
addContentsRow.setTextMaxEms(cellMaxEms);
addContentsRow.setTextSize(cellTextSize);
addContentsRow.setTabRowHeight(cellHeight);
tableLayout.addView(addContentsRow.addTableRow());
tableLayout.addView(divisionRow.addTableRow());
* 设置表格的背景
* @resId 背景的Id
public void setTableCellBackground(int resId){
this.resId = resId;
public void setTableCellBaackgroundColor(int color){
this.backgroudColor =
* 如果表格显示的是文字,设置文字每一行显示的字长
public void setTableCellMaxEms(int length){
this.cellMaxEms =
public void setTableCellTextSize(int size){
this.cellTextSize =
public void setTableCellTextColor(int color){
this.cellTextColor =
public void setTableCellHeight(int height){
this.cellHeight =
/********************私有成员***************************/
* 界面的初始化
void initWidge(){
this.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
//水平的滚动条
HorizontalScrollView horizontalScrollView = new HorizontalScrollView(getContext());
horizontalScrollView.setLayoutParams(new LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
horizontalScrollView.setFillViewport(true);
tableLayout = new TableLayout(getContext());
//表格布局
tableLayout.setLayoutParams(new HorizontalScrollView.LayoutParams(
HorizontalScrollView.LayoutParams.MATCH_PARENT,HorizontalScrollView.LayoutParams.MATCH_PARENT));
tableLayout.setStretchAllColumns(true);
//所有的列都可以被拉伸
horizontalScrollView.addView(tableLayout);
this.addView(horizontalScrollView);
protected void onLayout(boolean changed, int l, int t, int r, int b) {
// TODO Auto-generated method stub
super.onLayout(changed, l, t, r, b);
表格中每一行,包括表头行,表内容行,表格水平分割行,他们都共同继承与AddRow,,这样你想以后扩展就比较方便了
import android.content.C
import android.graphics.C
import android.view.V
import android.widget.TableL
import android.widget.TableR
public abstract class AddRow {
protected C
protected int color = Color.RED;
//分隔颜色
protected int width = 1;
//设置分隔线的宽的,包括垂直和水平的分割线
protected int height = TableRow.LayoutParams.WRAP_CONTENT;//定义这个这一行的高度
//一个默认的tabRow的布局参数
protected TableLayout.LayoutParams params = new TableLayout.LayoutParams(
TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
public AddRow(Context context) {
this.context =
public TableRow addTableRow();
* 设置分割线的颜色
public void setDivisonColor(int color){
this.color =
* 设置分割线的宽度
public void setDivisonWidth(int width){
this.width =
* 设置tabRow的布局参数
* 当然其宽度是无法设置的,这里只能设置高度
public void setTabRowHeight(int height){
params = new TableLayout.LayoutParams(height
, TableLayout.LayoutParams.WRAP_CONTENT);
* 水平竖直分割线
View addDivision(){
= new View(context);
TableRow.LayoutParams params= new TableRow.LayoutParams(width,TableRow.LayoutParams.MATCH_PARENT);
view.setLayoutParams(params);
view.setBackgroundColor(color);
mport android.content.C
import android.graphics.C
import android.view.G
import android.widget.TableR
import android.widget.TextV
public class AddHeadRow extends AddRow {
private String[]
private int textColor = Color.BLACK;
private int textLenghtMax = 10;
//定于每一行最多显示几个字
private int cellBackgroundColor = Color.WHITE;
public AddHeadRow(Context context,String[] header) {
super(context);
this.context =
this.header =
* 设置字体的颜色
public void setTextClor(int color){
this.textColor =
* 设置每一行的的字符数
public void setTextMaxEms(int lenght){
this.textLenghtMax =
* 设置表格的背景颜色 默认为白色
void setBackgroundColor(int color){
this.cellBackgroundColor =
public TableRow addTableRow(){
TableRow tableRow = new TableRow(context);
tableRow.addView(addDivision());
//添加分隔符号
tableRow.setLayoutParams(params);
for(int i = 0;i&header.i++){
TextView textView = new TextView(context);
TableRow.LayoutParams params = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.MATCH_PARENT);
textView.setLayoutParams(params);
textView.setGravity(Gravity.CENTER|Gravity.CENTER);
//文本居中显示
textView.setTextColor(textColor); //设置文本颜色
textView.setSingleLine(false);
textView.setMaxEms(textLenghtMax);
textView.setBackgroundColor(cellBackgroundColor); //设施背景颜色
textView.setText(header[i]);
tableRow.addView(textView);
tableRow.addView(addDivision());
return tableR
表内容(可以包含图片)当然你也可以包含自己的内容格式,只需要继承于AddRow
import android.content.C
import android.graphics.C
import android.view.G
import android.widget.ImageV
import android.widget.TableR
import android.widget.TextV
* 添加内容
public class AddContentsRow extends AddRow {
private Object[]
//表格填充内容
private int[]
//那些行为图片的信息?
private int resId;
private int backcolor = Color.WHITE; // 默认背景为白色
private boolean isBackground =
private int textMaxlength = 10;// 如果有文本信息,则文本信息的长度
private int textColor = Color.BLACK;
private int textSize = 18; // 文字大小 如果是文本的信息
public AddContentsRow(Context context, Object[] objects, int[] columns) {
super(context);
// TODO Auto-generated constructor stub
this.objects =
this.columns =
* 设置背景的颜色
public void setBackground(int resId) {
this.resId = resId;
isBackground =
public void setBackColor(int color) {
this.backcolor =
isBackground =
public void setTextMaxEms(int size){
this.textMaxlength =
public void setTextSize(int size){
this.textSize =
public void setTextColor(int color){
this.textColor =
public TableRow addTableRow() {
// TODO Auto-generated method stub
TableRow tableRow = new TableRow(context);
tableRow.addView(addDivision());
tableRow.setLayoutParams(params);
for (int i = 0; i & objects. i++) {
if (judeColumns(i, columns) == -1) { // 说明这一行不是显示图片
TextView textView = new TextView(context);
textView.setClickable(true);
textView.setGravity(Gravity.CENTER | Gravity.CENTER);
if (isBackground) {
textView.setBackgroundResource(resId);
textView.setBackgroundColor(backcolor);
TableRow.LayoutParams params = new TableRow.LayoutParams(
TableRow.LayoutParams.WRAP_CONTENT,
TableRow.LayoutParams.MATCH_PARENT);
textView.setLayoutParams(params);
textView.setSingleLine(false);
textView.setMaxEms(textMaxlength);
textView.setTextColor(textColor);
textView.setTextSize(textSize);
textView.setText((String) objects[i]);
tableRow.addView(textView);
// 添加分割线
tableRow.addView(addDivision());
ImageView imageView = new ImageView(context);
imageView.setBackgroundResource((Integer) objects[i]);
tableRow.addView(imageView);
// 添加分割线
tableRow.addView(addDivision());
return tableR
// 判断第几列是显示图片的
private int judeColumns(int i, int[] columnsImage) {
int j = columnsImage.
for (int z = 0; z & z++) {
if (columnsImage[z] == i) {
return -1;
水平分割线(分割线其实就是一个TabRow 只不过是里面只有一个view)
import android.content.C
import android.graphics.C
import android.view.V
import android.widget.TableR
public class AddDivisionRow extends AddRow {
public AddDivisionRow(Context context) {
super(context);
// TODO Auto-generated constructor stub
public TableRow addTableRow() {
// TODO Auto-generated method stub
TableRow tableRow = new TableRow(context);
tableRow.setLayoutParams(params);
tableRow.setBackgroundColor(color);
= new View(context);
TableRow.LayoutParams params1= new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, width);
view.setLayoutParams(params1);
view.setBackgroundColor(Color.RED);
tableRow.addView(view);
return tableR
看看主界面
import java.util.ArrayL
import java.util.L
import com.k.ktable.KtableV
import android.os.B
import android.app.A
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
KtableView ktableView = (KtableView)findViewById(R.id.ktable);
String header[] = {"姓名","年龄","爱好","任务"};
Object test1[] = {"李","21","分割跟个倒萨当断失断等四大大打啊倒萨 大 大的大额的是",R.drawable.alert_reda};
Object test2[] = {"李","22","b3",R.drawable.ic_launcher};
Object test3[] = {"李","23","c3",R.drawable.ic_launcher};
Object test4[] = {"李","24","d3",R.drawable.alert_reda};
List&Object[]& list = new ArrayList&Object[]&();
list.add(test1);
list.add(test2);
list.add(test3);
list.add(test4);
int[] b ={3}; //第三行显示的是图片
ktableView.setTableHeaders(header);
ktableView.setTableCellMaxEms(5);
ktableView.addNewRow(test1, b);
ktableView.addNewRow(test2, b);
ktableView.setTableCellBackground(R.drawable.down_up);
ktableView.addNewRow(test3, b);
ktableView.addNewRow(test4, b);
ktableView.addNewRow(test1, b);
在布局中使用我的控件方式
&com.k.ktable.KtableView
android:id="@+id/ktable"
android:layout_width="match_parent"
android:layout_height="match_parent"
&&/com.k.ktable.KtableView&
好了这样的表格出来了,如果需要整个完整的工程或者,留言给你发邮件
&&&&推荐文章:
【上篇】【下篇】

我要回帖

更多关于 ios 分割线颜色 的文章

 

随机推荐