【发布时间】:2012-06-20 02:42:58
【问题描述】:
我正在尝试将textView 添加到frameLayout。 TextView 具有 wrap_content 属性,因此它会随着文本的增长而增长。我用这个函数将它添加到FrameLayout:
((FrameLayout) findViewById(R.id.mainLayout)).addView(mEditText);
这是框架布局的xml:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</FrameLayout>
textView 总是出现在屏幕的左上角。我想把它放在中间,或者顶部中间。如何做到这一点?
我查看了How can I dynamically set the position of view in Android? 中的答案,它们并没有太大帮助:( 主要是导致崩溃..
【问题讨论】:
标签: android textview android-framelayout