4

setContentViewを呼び出してXMLレイアウトを表示することはできません-プログラムで変更できるRelativeLayoutしか取得できません。ここで、私が行う必要があるのは、RelativeLayoutの下部に配置された単純なTextViewを追加することです。XMLを使用すると、次のように簡単になります。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true" 
    android:maxLines="5"
    android:scrollbars="vertical"
    android:text="some text"
    />
</RelativeLayout>

私はこれをコードでさまざまな方法で試してきましたが、正しく機能させることができません。textView.setGravity(Gravity.BOTTOM)とrelativeLayout.setVerticalGravity(RelativeLayout.ALIGN_PARENT_BOTTOM)を試しましたが、機能しませんでした。パディングすることで押し下げることはできますが、画面全体に表示したくありません。

4

0 に答える 0