他の質問を調べましたが、このシナリオに完全に一致するものは見つかりませんでした。XMLでRelativeLayoutを定義しました。このRelativeLayout全体を(個別に作成したクラスの)GraphViewオブジェクトの下に配置したいと思います。私は、RelativeLayoutをGraphViewの下に配置する最良の方法は、プログラムで定義しようとしたLinearLayout内にこれらの両方を貼り付けることであると考えました。
これは私がこれまでに持っているものです-それに何か問題がありますが、私はよくわかりません。
import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
public class Grapher extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
LinearLayout ll = new LinearLayout(this);
GraphView gv = new GraphView(this);
RelativeLayout rl = (RelativeLayout) findViewById(R.id.mainRelativeLayout);
ll.addView(gv);
ll.addView(rl);
setContentView(ll);
そして、xml...。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/mainRelativeLayout"
android:orientation="vertical">
<Button
android:id="@+id/second"
android:clickable="true"
android:background="@drawable/button_chooser"
android:layout_width="70dp"
android:layout_height="40dp"
android:text="@string/second"
android:textColor="@color/white"
android:textSize="15sp"/>
<Button
android:id="@+id/alpha"
android:clickable="true"
android:background="@drawable/button_chooser"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_below="@id/second"
android:layout_alignParentLeft="true"
android:text="@string/alpha"
android:textColor="@color/white"
android:textSize="15sp" />
<Button
android:id="@+id/mode"
android:clickable="true"
android:background="@drawable/button_chooser"
android:layout_width="70dp"
android:layout_height="40dp"
android:layout_toRightOf="@id/second"
android:text="@string/mode"
android:textColor="@color/white"
android:textSize="15sp" />
</RelativeLayout>
ご協力いただきありがとうございます。私はこれが私が見ている非常に単純なものであるという予感があります。