我试图让ListView的背景透明化。我已经弄清楚除了我的XYPlot在ListView不移动时的所有情况下如何做到这一点。无论我尝试什么,背景总是在停止时看起来是黑色的(移动时它是透明的)。
以下是我正在使用的图片:
这是我的listview的xml:
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@android:color/transparent"
android:dividerHeight="3sp"
android:cacheColorHint="#00000000"
/>
这是我的XYPlot的xml:
<com.androidplot.xy.XYPlot
android:id="@+id/trend_plot"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight=".5"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"/>
以下是我的图表格式:
//clear the previous info
graph.clear();
//Remove the legend
graph.getLayoutManager().remove(graph.getLegendWidget());
//Remove lines and format
Paint backgroundPaint = new Paint();
backgroundPaint.setColor(Color.TRANSPARENT);
backgroundPaint.setStyle(Paint.Style.FILL);
graph.getBorderPaint().setColor(Color.TRANSPARENT);
graph.setBackgroundColor(Color.TRANSPARENT);
graph.setBackgroundPaint(backgroundPaint);
graph.getGraphWidget().getBackgroundPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getCursorLabelBackgroundPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getCursorLabelPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getDomainGridLinePaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getDomainLabelPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getDomainOriginLabelPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getDomainSubGridLinePaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getGridBackgroundPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getRangeGridLinePaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getRangeLabelPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getRangeOriginLabelPaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().getRangeSubGridLinePaint().setColor(Color.TRANSPARENT);
graph.getGraphWidget().setRangeLabelOrientation(-400);
graph.getRangeLabelWidget().getLabelPaint().setTextSize(20);
graph.getRangeLabelWidget().setText("Votes");
graph.getDomainLabelWidget().getLabelPaint().setTextSize(20);
graph.getDomainLabelWidget().setText("Time");
graph.getTitleWidget().setPaddingTop(20);
graph.getTitleWidget().setPaddingBottom(20);
graph.getTitleWidget().getLabelPaint().setTextSize(20);
graph.getTitleWidget().setText("Popularity");
graph.setRangeBoundaries(0, 100, BoundaryMode.FIXED);
之前有没有人处理过这样的事情?我只是想让图表背景始终保持透明。
答案 0 :(得分:1)
您是否尝试过添加
android:background="@android:color/transparent"
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:divider="@android:color/transparent"
android:background="@android:color/transparent"
android:dividerHeight="3sp"
android:cacheColorHint="#00000000"
/>
答案 1 :(得分:1)
plot.setBorderStyle(Plot.BorderStyle.NONE, null, null);
plot.setPlotMargins(0, 0, 0, 0);
plot.setPlotPadding(0, 0, 0, 0);
plot.setGridPadding(0, 0, 0, 0);
plot.setBackgroundColor(Color.WHITE);
plot.getGraphWidget().getBackgroundPaint()
.setColor(Color.WHITE);
plot.getGraphWidget().getGridBackgroundPaint()
.setColor(Color.WHITE);
LayoutManager lm = plot.getLayoutManager();
XYGraphWidget g = plot.getGraphWidget();
// plot = new XYPlot(getApplicationContext(), "",
// Plot.RenderMode.USE_MAIN_THREAD);
g.setGridPaddingLeft(0);
g.setGridPaddingRight(0);
g.setMarginLeft(0);
g.position(-0.5f, XLayoutStyle.RELATIVE_TO_RIGHT,
-0.5f, YLayoutStyle.RELATIVE_TO_BOTTOM,
AnchorPosition.CENTER);
g.setSize(new SizeMetrics(0, SizeLayoutType.FILL, 0,
SizeLayoutType.FILL));