Android double row sliding table (the double table does not move) and android double row sliding table
※Effect
※Usage
package com.cd.slidetest;import android.os.Bundle;import android.app.Activity;import android.graphics.Color;import android.view.GestureDetector;import android.view.Menu;import android.view.MotionEvent;import android.view.GestureDetector.SimpleOnGestureListener;import android.widget.LinearLayout;import android.widget.LinearLayout.LayoutParams;import android.widget.ScrollView;public class MainActivity extends Activity implements OnScrollChangedListener{private GestureDetector mGestureDetector = null;private HScrollView mItemRoom = null;private ScrollView mVertical = null;private HScrollView mTimeItem = null;private LinearLayout mContain = null;@SuppressWarnings("deprecation")@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);mGestureDetector = new GestureDetector(mGestureListener);makeItems();setContentView(mContain);}@Overridepublic boolean onCreateOptionsMenu(Menu menu) {getMenuInflater().inflate(R.menu.main, menu);return true;}private void makeItems(){mItemRoom = new HScrollView(this, mGestureDetector);mItemRoom.setListener(this);LinearLayout VLayout = new LinearLayout(this);VLayout.setOrientation(LinearLayout.VERTICAL);for(int i = 0;i < 20;i++){LinearLayout HLayout = new LinearLayout(this);for(int j = 0;j < 10;j++){TextItem item = new TextItem(this);item.setText(i*10+j + "vh");item.setBackgroundColor(Color.LTGRAY);LinearLayout.LayoutParams params = new LayoutParams(100,70);HLayout.addView(item, params);}VLayout.addView(HLayout);}mItemRoom.addView(VLayout);mVertical = new ScrollView(this);LinearLayout hlayout = new LinearLayout(this);LinearLayout vlayout = new LinearLayout(this);vlayout.setOrientation(LinearLayout.VERTICAL);for(int i = 0;i < 20;i++){TextItem item = new TextItem(this);item.setBackgroundColor(Color.BLUE);item.setText(i + "v");LinearLayout.LayoutParams params = new LayoutParams(100,70);vlayout.addView(item, params);}hlayout.addView(vlayout);hlayout.addView(mItemRoom);mVertical.addView(hlayout);LinearLayout tophlayout = new LinearLayout(this);mTimeItem = new HScrollView(this, mGestureDetector);mTimeItem.setListener(this);LinearLayout layout = new LinearLayout(this);for(int i = 0;i < 10;i++){TextItem item = new TextItem(this);item.setText(i + "h");item.setBackgroundColor(Color.GREEN);LinearLayout.LayoutParams params = new LayoutParams(100,70);layout.addView(item,params);}mTimeItem.addView(layout);TextItem item = new TextItem(this);item.setBackgroundColor(Color.RED);LinearLayout.LayoutParams params = new LayoutParams(100,70);tophlayout.addView(item,params);tophlayout.addView(mTimeItem);mContain = new LinearLayout(this);mContain.setOrientation(LinearLayout.VERTICAL);mContain.addView(tophlayout);mContain.addView(mVertical);}private SimpleOnGestureListener mGestureListener = new SimpleOnGestureListener(){@Overridepublic boolean onScroll(MotionEvent e1, MotionEvent e2,float distanceX, float distanceY) {if(Math.abs(distanceX) > Math.abs(distanceY)) { return true;}return false;}};@Overridepublic void onScrollChanged(HScrollView scroll, int x, int y, int oldx,int oldy) {if(scroll == mItemRoom){mTimeItem.scrollTo(x, y);}else if(scroll == mTimeItem){mItemRoom.scrollTo(x, y);}}}
※
Http://download.csdn.net/detail/u010785585/8062787
The excel table header does not understand, and the content can be slide. How can this problem be made?
Upstairs, click menu-freeze pane.
In addition, there is a tip. In the menu-page settings-worksheet column, there is a top heading line, click the red arrow button, select the name line, and click OK. In this way, no matter how many pages the table has, each page is printed with a name.
How can I set the table header to move without moving the remaining cells?
You are talking about the "Freeze pane" function.
Drag the top right side of the window (the top of the vertical scroll bar) to split the window horizontally into the upper and lower parts, and then press "window-freeze pane.
Similarly, in the lower right side of the window (right end of the horizontal scroll bar), you can vertically split the window into the left and right sides, and then freeze spaces.
The shortcut is to select the active cell to be split as the dividing line, and directly press "window-freeze space ".