0

非常に奇妙な問題があります。誰かがこれが何であるかを知っていることを願っています。スクロール可能なビューで、太いセルの境界線が 2px のテーブルを作成します。タブレット (Samsung galaxy 10.1) では完璧ですが、galaxy tab 2 では、スクロール ビューの表示部分でのみ境界線の描画が「停止」します。違いを示すために2枚の写真を添付し​​ます サムスン Galaxy タブ 10.1

Samsung Galaxy Tab 2 (少し右にスクロール)

Java部分のコードは次のとおりです。

  @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            super.onCreateView(inflater, container, savedInstanceState);
            scrollView1=(HorizontalScrollView) firstView.findViewById(R.id.horizontalScrollView1);
            //position the scroller to the present time
            scrollView1.post(new Runnable() { 
                public void run() { 
                    if((Calendar.getInstance().get(Calendar.HOUR_OF_DAY)>3))
                     scrollView1.scrollTo(CELL_WIDTH*((Calendar.getInstance().get(Calendar.HOUR_OF_DAY))-3), 0);
                } 
        });

             headerPaint = new Paint();
             headerPaint.setStyle(Paint.Style.STROKE);
             headerPaint.setColor(Color.GRAY);
             headerPaint.setStrokeWidth(2);

             cellPaint = new Paint();
             cellPaint.setStyle(Paint.Style.STROKE);
             cellPaint.setColor(Color.GRAY);
             cellPaint.setStrokeWidth(2);

            textViewData.setText(formatter.format(dateToShow.getTime()));
            imageButtonDateAfter.setOnClickListener(new View.OnClickListener() {
                public void onClick(View v) {
                    Calendar oggi = Calendar.getInstance();
                    oggi.set(Calendar.HOUR_OF_DAY, 23);
                    oggi.set(Calendar.MINUTE, 59);
                    dateToShow.add(Calendar.DAY_OF_MONTH, 1);   
                }
            });
            loadElementiInTable();
            return firstView;
        }

//for space reasons i show you only the first row code (the hours of the day)
 private void loadElementiInTable() {
        tableLayoutElementi.removeAllViews();
        tableLayoutHeader.removeAllViews();
        ArrayList<Integer> orari = new ArrayList<Integer>();
        orari = loadListOrari();
        listPasti = new ArrayList<Pasto>();
        listGlicemie = new ArrayList<Glicemia>();
        listBoli = new ArrayList<Administration>();
        TableRow hoursRow=new TableRow(getActivity().getApplicationContext());
        TableRow hoursHeaderRow=new TableRow(getActivity().getApplicationContext());
        TableRow hoursSepRow = new TableRow(getActivity().getApplicationContext());
        TextView legendanew=new TextView(getActivity().getApplicationContext());

        legendanew.setText("Campo");
        legendanew.setWidth(HEADER_WIDTH);
        legendanew.setGravity(Gravity.CENTER);
        hoursHeaderRow.addView(legendanew);

        for (final Integer j : orari) {
        TextView ora1=new TextView(getActivity().getApplicationContext()){
            @Override
            protected void onDraw(Canvas canvas) {
                super.onDraw(canvas);
                Rect rect = new Rect();
                Paint paint = new Paint();
                paint.setStyle(Paint.Style.STROKE);
                paint.setColor(Color.GRAY);
                paint.setStrokeWidth(2);
                getLocalVisibleRect(rect);
                canvas.drawRect(rect, paint);       
            }

        };
        ora1.setTextColor(Color.DKGRAY);
        ora1.setGravity(Gravity.CENTER);
        TextView sepOra=new TextView(getActivity().getApplicationContext());
        ora1.setText(j+":00");
        if(j==Calendar.getInstance().get(Calendar.HOUR_OF_DAY)){
            ora1.setBackgroundColor(Color.YELLOW);
        }
        ora1.setWidth(CELL_WIDTH);
        hoursRow.addView(ora1);
        //hoursRow.addView(sepOra);
        }

        TableRow glicemiaRow = new TableRow(getActivity().getApplicationContext());
        TableRow glicemiaHeaderRow = new TableRow(getActivity().getApplicationContext());
        TextView glicemiaLabel=new TextView(getActivity().getApplicationContext()){
            @Override
            protected void onDraw(Canvas canvas) {
                super.onDraw(canvas);
                Rect rect = new Rect();
                getLocalVisibleRect(rect);
                canvas.drawRect(rect, headerPaint);       
            }

        };
        glicemiaLabel.setText("Glicemia");
        formatAsHeader(glicemiaLabel);  
        glicemiaHeaderRow.addView(glicemiaLabel);
        TextView glicemiaTuttoIlGiorno=new TextView(getActivity().getApplicationContext()){
            @Override
            protected void onDraw(Canvas canvas) {
                super.onDraw(canvas);
                Rect rect = new Rect();
                getLocalVisibleRect(rect);
                canvas.drawRect(rect, cellPaint);       
            }
        };
        if(showTuttoIlGiorno){
        glicemiaTuttoIlGiorno.setText(EMPTY_CELL);
        formatAsTuttoIlGiorno(glicemiaTuttoIlGiorno);
        glicemiaHeaderRow.addView(glicemiaTuttoIlGiorno);
        }

        tableLayoutElementi.setStretchAllColumns(true);
        legendanew.setWidth(100);
        noteRow.setBaselineAligned(false);
        noteHeaderRow.setBaselineAligned(false);
        tableLayoutElementi.addView(noteRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        tableLayoutHeader.addView(noteHeaderRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        boloRow.setBaselineAligned(false);
        boloHeaderRow.setBaselineAligned(false);
        tableLayoutElementi.addView(boloRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        tableLayoutHeader.addView(boloHeaderRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        pastoRow.setBaselineAligned(false);
        pastoHeaderRow.setBaselineAligned(false);
        tableLayoutElementi.addView(pastoRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        tableLayoutHeader.addView(pastoHeaderRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        glicemiaRow.setBaselineAligned(false);
        glicemiaHeaderRow.setBaselineAligned(false);
        tableLayoutElementi.addView(glicemiaRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        tableLayoutHeader.addView(glicemiaHeaderRow, 0, new TableLayout.LayoutParams(100, CELL_HEIGHT));
        tableLayoutHeader.addView(hoursHeaderRow, 0, new TableLayout.LayoutParams(100, heightColonna));
        tableLayoutElementi.addView(hoursRow, 0, new TableLayout.LayoutParams(100, heightColonna));
    }
    }

xml ファイル (テーブル部分のみ):

 <RelativeLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="10" >

        <HorizontalScrollView
            android:id="@+id/horizontalScrollView1"
            android:layout_width="1080dp"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true" >

            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="fill_parent" >

            <TableLayout
                android:id="@+id/tableLayoutElementi"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:background="@color/white" >
            </TableLayout>

 </LinearLayout>

            </HorizontalScrollView>

        <LinearLayout
            android:id="@+id/headerleft"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="vertical" >

            <TableLayout
                android:id="@+id/tableLayoutHeader"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >

                <TableRow
                    android:id="@+id/tableRow1"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TextView
                        android:id="@+id/textView1"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TextView" />

                </TableRow>

                <TableRow
                    android:id="@+id/tableRow2"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TextView
                        android:id="@+id/textView2"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TextView" />

                </TableRow>

                <TableRow
                    android:id="@+id/tableRow3"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >
                    <TextView
                        android:id="@+id/textView3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="TextView" />
                </TableRow>
                <TableRow
                    android:id="@+id/tableRow4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >
                </TableRow>
            </TableLayout>
        </LinearLayout>
    </RelativeLayout>
4

1 に答える 1