ビュー上のテキストを見つける必要があります:
text'もう少しテキスト'はbottom|center_horizontalに配置する必要があります
text'Short text'は、右揃えで配置する必要がありますが、画面の上部から約10%
テキスト「xxxx」は画面の中央に揃える必要があります(第1クォーターの右/下揃え)
text'一部の長いテキスト..'は、画面の第3クォーターの左上に配置する必要がありますが、画面のcenter_horizontalと交差する必要があります。
ビュー上のテキストを見つける必要があります:
text'もう少しテキスト'はbottom|center_horizontalに配置する必要があります
text'Short text'は、右揃えで配置する必要がありますが、画面の上部から約10%
テキスト「xxxx」は画面の中央に揃える必要があります(第1クォーターの右/下揃え)
text'一部の長いテキスト..'は、画面の第3クォーターの左上に配置する必要がありますが、画面のcenter_horizontalと交差する必要があります。
ここにいくつかの簡単なガイドラインがあります:
もう一度あなたの図を見て、私はそれをこのように再現しました:
残念ながら、ステップ4の何も正しく機能しませんでした。参照されるアイテムがcenterInParentアイテムである場合、「layout_below」のようなものは機能しませんでした。手順3の相対レイアウトを使用します。トップレベルでfill_contentを失敗したことに関係していることがわかりました。はい、レイアウトには注意が必要です。デバッガーがあればいいのにと思います。
正しいバージョンは次のとおりです。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/r1"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="@+id/short_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Short Text"
android:gravity="right"
android:layout_marginTop="30dip"
android:layout_alignParentTop="true" />
<TextView
android:id="@+id/more_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Some More Text"
android:gravity="center"
android:layout_alignParentBottom="true" />
<TextView android:id="@+id/centerpoint"
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="0dip"
android:height="0dip"
/>
<TextView android:id="@+id/run_fox"
android:text="Run, fox, run!"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@id/centerpoint"
android:layout_toLeftOf="@id/centerpoint"
/>
<TextView
android:layout_below="@id/centerpoint"
android:text="The quick brown fox jumped over the lazy dog, who had been a frog, and then got features and ran slowly."
android:layout_alignRight="@id/centerpoint"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</RelativeLayout>
私が正しく理解しているなら、あなたは単にテキストビューに真剣な文字列を置きたいと思うでしょう。これはXMLで行うことができます。このための便利なGUIツールはDroidDrawです。ブラウザまたはデスクトップで実行できます。私はそれがいくつかのGUIのものに便利だと思います。それ以外に、このようなビューを描くことができます...
class DrawOnTop extends View {
public DrawOnTop(Context context) {
super(context);
// TODO Auto-generated constructor stub
}
@Override
public void onDraw(Canvas canvas) {
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
paint.setColor(Color.RED);
paint.setTextSize(15);
Paint paint2 = new Paint();
canvas.drawText("Test", 30, 30, paint);
}
}
上記の例では、新しいペイントを定義しました。これは、テキストのプロパティを設定するためのものです。赤い色とテキストサイズ15を指定しました。属性をさらに追加することもできます。「テスト」という文字列も描画しました。座標(30,30)にあります。これらは、Javaで描画するx座標とy座標です。次に、ペイントの属性を使用します。
編集:このページも役立つかもしれませんhttp://developer.android.com/reference/android/graphics/Canvas.html