請問我該如何將TextView放到屏幕的底部?我發現了一些基於xml的解決方案,但是在java中編寫代碼時沒有任何解決方案Android:我怎樣才能把TextView放到java屏幕的底部
TextView myText= new TextView(this);
myText.setText("some text");
在這種情況下,位置就在左上角。 我的XML是:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<TextView android:text="@string/hello_world" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/textView" />
</RelativeLayout>
發佈您的XML請告訴我們你需要它準確放置在哪裏。 –
我的xml幾乎是空的。我不使用xml或圖形佈局來通過鼠標在此應用程序中放置元素。當我僅使用按鈕(我通過循環動態生成)時,我沒有任何問題。我可以使用AddButtonLayout,但是我找不到像textView那樣的東西。 –
即使您的佈局爲空,我們也需要它,因爲您仍然必須至少引用父視圖才能爲其添加視圖。請張貼它。謝謝。 –