0
我創建了一個GraphicalView
(a CombinedXYChartView
)並將其添加到我的版式中。接下來,我想添加一些CheckBoxes
低於 my GraphicalView。AChartEngine - GraphicalView始終匹配父項
問題是,GraphicalView總是匹配父母,這就是爲什麼我看不到我的CheckBoxes(因爲沒有空間)。
下面是截圖:
這裏是我的代碼(剪斷):
layout_chart.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_color"
android:orientation="vertical" >
<!-- layout for chart -->
<LinearLayout
android:id="@+id/linearLayout_chart"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
</LinearLayout>
<!-- layout for checkboxes -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="checkBox1" />
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:checked="true"
android:text="checkBox2" />
</LinearLayout>
</LinearLayout>
FragmentChart.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
LinearLayout v = (LinearLayout) inflater.inflate(R.layout.layout_chart, container, false);
graphicalView = initChart(); // Creating CombinedXYChartView
LinearLayout layout = (LinearLayout) v.findViewById(R.id.linearLayout_chart);
layout.addView(graphicalView, new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT));
return v;
}
該圖表完美無缺。還有複選框,如果我禁用圖表。所以有什麼問題?
是的,我剛剛以同樣的方式解決了問題(並輸入了答案)。總是一樣的...我試圖找到一個解決方案大約1-2小時,並且在我問了一個關於stackoverflow的問題後不久我就爲自己找到了答案。但是,無論如何,謝謝! – Namenlos