当前位置: 编程技术>移动开发
本页文章导读:
▪首先行第一列不滚动,其他行列可以上下水平滚动 第一行第一列不滚动,其他行列可以上下水平滚动
这种情况应该对于股票的软件应用较多,好多人问,我也没做过这个时机项目,简单的写了一下,只是给大家一个提示:
public void onCreate.........
▪ 装配apk、卸载apk 代码 安装apk、卸载apk 代码
安装 apk:
Intent i = new Intent(Intent.ACTION_VIEW);
String filePath = appInfo.getAbsolutePath();.........
▪ TextView根本使用 TextView基本使用
改变背景颜色:Resources resources = getBaseContext().getResources();Drawable HippoDrawable = resources.getDrawable(R.drawable.white);mTextView.setBackgroundDrawable(HippoDrawable);改变字体颜色:mTextView.setTextC.........
[1]首先行第一列不滚动,其他行列可以上下水平滚动
来源: 互联网 发布时间: 2014-02-18
第一行第一列不滚动,其他行列可以上下水平滚动
这种情况应该对于股票的软件应用较多,好多人问,我也没做过这个时机项目,简单的写了一下,只是给大家一个提示:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.table_layout); TableRow.LayoutParams wrapWrapTableRowParams = new TableRow.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); int[] fixedColumnWidths = new int[]{20, 20, 20, 20, 20}; int[] scrollableColumnWidths = new int[]{20, 20, 20, 30, 30}; int fixedRowHeight = 50; int fixedHeaderHeight = 60; TableRow row = new TableRow(this); TableLayout header = (TableLayout) findViewById(R.id.table_header); row.setLayoutParams(wrapWrapTableRowParams); row.setGravity(Gravity.CENTER); row.setBackgroundColor(Color.YELLOW); row.addView(makeTableRowWithText("col 1", fixedColumnWidths[0], fixedHeaderHeight)); row.addView(makeTableRowWithText("col 2", fixedColumnWidths[1], fixedHeaderHeight)); row.addView(makeTableRowWithText("col 3", fixedColumnWidths[2], fixedHeaderHeight)); row.addView(makeTableRowWithText("col 4", fixedColumnWidths[3], fixedHeaderHeight)); row.addView(makeTableRowWithText("col 5", fixedColumnWidths[4], fixedHeaderHeight)); header.addView(row); TableLayout fixedColumn = (TableLayout) findViewById(R.id.fixed_column); TableLayout scrollablePart = (TableLayout) findViewById(R.id.scrollable_part); for(int i = 0; i < 10; i++) { TextView fixedView = makeTableRowWithText("row number " + i, scrollableColumnWidths[0], fixedRowHeight); fixedView.setBackgroundColor(Color.BLUE); fixedColumn.addView(fixedView); row = new TableRow(this); row.setLayoutParams(wrapWrapTableRowParams); row.setGravity(Gravity.CENTER); row.setBackgroundColor(Color.WHITE); row.addView(makeTableRowWithText("value 2", scrollableColumnWidths[1], fixedRowHeight)); row.addView(makeTableRowWithText("value 3", scrollableColumnWidths[2], fixedRowHeight)); row.addView(makeTableRowWithText("value 4", scrollableColumnWidths[3], fixedRowHeight)); row.addView(makeTableRowWithText("value 5", scrollableColumnWidths[4], fixedRowHeight)); scrollablePart.addView(row); } } private TextView recyclableTextView; public TextView makeTableRowWithText(String text, int widthInPercentOfScreenWidth, int fixedHeightInPixels) { int screenWidth = getResources().getDisplayMetrics().widthPixels; recyclableTextView = new TextView(this); recyclableTextView.setText(text); recyclableTextView.setTextColor(Color.BLACK); recyclableTextView.setTextSize(20); recyclableTextView.setWidth(widthInPercentOfScreenWidth * screenWidth / 100); recyclableTextView.setHeight(fixedHeightInPixels); return recyclableTextView; }
<?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:gravity="center_horizontal" android:id="@+id/fillable_area"> <TableLayout android:id="@+id/table_header" android:layout_width="fill_parent" android:layout_height="wrap_content"/> <ScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:gravity="center_horizontal" android:id="@+id/fillable_area"> <TableLayout android:id="@+id/fixed_column" android:layout_width="wrap_content" android:layout_height="wrap_content"/> <HorizontalScrollView android:layout_width="fill_parent" android:layout_height="wrap_content"> <TableLayout android:id="@+id/scrollable_part" android:layout_width="fill_parent" android:layout_height="fill_parent"/> </HorizontalScrollView> </LinearLayout> </ScrollView> </LinearLayout>
1 楼
mailyiran200101
2011-11-08
学些了,以前都是直接做的布局,比较差的方法
2 楼
xieyt
2011-11-17
你好,请问横向的时候 怎么才能上第一行也可以滚动啊
[2] 装配apk、卸载apk 代码
来源: 互联网 发布时间: 2014-02-18
安装apk、卸载apk 代码
安装 apk:
Intent i = new Intent(Intent.ACTION_VIEW);
String filePath = appInfo.getAbsolutePath();
i.setDataAndType(Uri.parse("file://" + filePath),
"application/vnd.android.package-archive");
startActivity(i);
卸载 apk:
Uri uri = Uri.fromParts("package",
appList.get(pos).getPackageName(),
null);
Intent intentuninstall = new Intent(Intent.ACTION_DELETE, uri);
startActivity(intentuninstall);
[3] TextView根本使用
来源: 互联网 发布时间: 2014-02-18
TextView基本使用
改变背景颜色:
Resources resources = getBaseContext().getResources();
Drawable HippoDrawable = resources.getDrawable(R.drawable.white);
mTextView.setBackgroundDrawable(HippoDrawable);
改变字体颜色:
mTextView.setTextColor(Color.RED);
置换文字:
CharSequence str1 = getString(R.string.str1);
mTextView.setText(str1+"11");
改变背景颜色:
Resources resources = getBaseContext().getResources();
Drawable HippoDrawable = resources.getDrawable(R.drawable.white);
mTextView.setBackgroundDrawable(HippoDrawable);
改变字体颜色:
mTextView.setTextColor(Color.RED);
置换文字:
CharSequence str1 = getString(R.string.str1);
mTextView.setText(str1+"11");
最新技术文章: