我在使用这段代码困难:安卓:如何申请的LayoutParams我的RelativeLayout
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
RelativeLayout layout = (RelativeLayout)findViewById(R.id.RelativeLayout1);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT);
我有我的RelativeLayout1在这样的XML:
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/ScrollView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingLeft="60dp"
android:paddingTop="53dp" >
但在我申请的时候scrollview,RelativeLayout1的fill_parent不能像它不是scrollview的子节点时那样工作。当它不是一个孩子时(即我完全移除滚动视图),那么相对布局覆盖整个屏幕,因为我喜欢它。但是当我把它放在scrollview中时,即使我使用了fill_parent,它也只能到达相关布局中的最后一个元素(一个按钮)。
所以我试图通过编程来查看它是否有所作为,但我似乎无法弄清楚如何将我的params变量应用到我的布局中的第一位代码。如果您有任何其他想法,请让我知道。
谢谢!这看起来不错。 – capcom 2012-07-31 13:20:03