一个小时后,感谢Tepis here,我在应用程序中安装了ToolBar。但是现在还有另一个“问题”,我不明白为什么看不到“图形视图”网格。 我将向您显示结果:
这是我的xml主要活动:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:orientation="vertical">
<android.support.design.widget.AppBarLayout
android:id="@+id/app_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay" />
</android.support.design.widget.AppBarLayout>
<com.google.android.gms.samples.vision.face.rPPG.ui.camera.CameraSourcePreview
android:id="@+id/preview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/app_bar"
>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_vertical|center_horizontal"
android:text="@string/no_faces_found"
android:textStyle="bold"
android:visibility="invisible" />
<TextView
android:id="@+id/info3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
android:background="#00ffffff"
android:text=""/>
<com.google.android.gms.samples.vision.face.rPPG.ui.camera.GraphicOverlay
android:id="@+id/faceOverlay"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</com.google.android.gms.samples.vision.face.rPPG.ui.camera.CameraSourcePreview>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="140dp"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:background="#000000"
android:orientation="vertical"
android:paddingLeft="16dp"
android:paddingRight="16dp">
<com.jjoe64.graphview.GraphView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/graph"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_weight="2"
android:orientation="horizontal">
<Button
android:id="@+id/faces"
android:layout_width="54dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_margin="8dp"
android:layout_weight="1"
android:theme="@style/MyButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:background="@drawable/bordismussati"
android:text="@string/number_of_faces" />
<Button
android:id="@+id/distance"
android:layout_width="53dp"
android:layout_height="match_parent"
android:layout_alignParentStart="true"
android:layout_margin="8dp"
android:layout_weight="1"
android:theme="@style/MyButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:background="@drawable/bordismussati"
android:text="@string/distance" />
<Button
android:id="@+id/display"
android:layout_width="7dp"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignTop="@+id/faces"
android:layout_margin="8dp"
android:layout_weight="2"
android:theme="@style/MyButton"
style="@style/Widget.AppCompat.Button.Borderless"
android:background="@drawable/bordismussati"
android:text="@string/display_info" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_weight="1"
android:orientation="horizontal">
<TextView
android:id="@+id/info"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_margin="8dp"
android:layout_weight="1"
android:background="@drawable/bordismussati"
android:gravity="center_vertical|center_horizontal"
android:text="@string/_0" />
<TextView
android:id="@+id/info2"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_margin="8dp"
android:layout_weight="1"
android:background="@drawable/bordismussati"
android:gravity="center_vertical|center_horizontal"
android:text="@string/no_faces_found" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
以及此处MainActivityrPPG.java文件中的图形视图:
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
GraphView graph= (GraphView) findViewById(R.id.graph);
series = new LineGraphSeries<>(new DataPoint[] {
});
graph.addSeries(series);
// activate horizontal and vertical zooming and scrolling
graph.getViewport().setScalableY(true);
// set manual X bounds
graph.getViewport().setXAxisBoundsManual(true);
graph.getViewport().setMinX(0.5);
graph.getViewport().setMaxX(100);
DatiRealTime();
}
private void DatiRealTime() {
mHandler.post(new Runnable() {
@Override
public void run() {
LastXPoint++;
series.appendData(new DataPoint(LastXPoint, plotRRG), false, 300);
mHandler.postDelayed(this, 1000);
}
});
}
我相信问题出在main_activity.xml文件中,但我找不到它在哪里。 有人可以建议我在哪里冤wrong吗? 预先感谢