私は以前これをやったと確信していますが、どうやって忘れてしまったのですか。ボタンの右側にTextViewを配置して中央揃えしますか?
ここに問題があります: 私はボタンとテキストビューを持っており、ボタンは左側にありますが、テキストビューを中央に揃えたいと思っています。
問題はありませんか?それらを相対的な位置に配置し、テキストビューを中央にし、ボタンをalignparentleftにします。
しかし、私は動的にテキストを変更しようとしているので、ボタンの上に書き込むことができます!私はちょうどtoRightOf = "@ id/button"をtextviewに追加します。いや、それはもはや中心に置かれていません。
私はスクリーンショットを提供したいと思いますが、コンピュータのメモリが不足していると思われます。ここで
は、いくつかのコードです:(?私は、XMLを貼り付けることはできませんので...)
http://pastebin.com/3N70Vjre
<RelativeLayout
android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true">
<Button
android:id="@+id/leftbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:text="text!"
/>
<TextView
android:id="@+id/toptext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@android:color/white"
android:layout_toRightOf="@id/leftbutton"
android:layout_centerInParent="true"
android:textSize="16sp"
android:textStyle="bold"
android:text="Text!"
android:singleLine="true"
/>
</RelativeLayout>
水平または垂直のセンタリングについて話していますか?どちらがうまくいっていて、どちらはどちらですか? – mibollma
私は水平センタリングについて話しています。 relativelayout内の垂直方向のセンタリングはうまくいきます。 – AmITheRWord