【发布时间】:2015-07-11 14:16:58
【问题描述】:
我在 main.xml 中定义了一个 RelativeLayout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
</RelativeLayout>
并在 onCreate 中以编程方式添加 TextView 和 EditText:
public void onCreate(Bundle savedInstanceState){
setContentView(R.layout.main);
addContentView(customGlView, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
addContentView(myTextView, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
addContentView(myEditText, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
}
它们都出现了,但在左上角重叠。我花了几个小时来弄清楚如何将它们放置在彼此下方,或者一个在屏幕的左角,另一个在右角。如果我通过 main.xml 添加它们,它们都不会出现。谁能给我一个正确方向的提示?
【问题讨论】:
标签: android android-layout android-relativelayout