XML:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<RelativeLayout
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
</RelativeLayout>
爪哇:
RelativeLayout layout = (RelativeLayout) findViewById(R.id.activity_main);
layout.setBackgroundResource(R.drawable.something);
layout.getLayoutParams().width = 900;
layout.getLayoutParams().height = 900;
宽度变为我设置的宽度,但无论我将其更改为什么高度都不会。我尝试将XML中的layout_height更改为10 dp,但这也没有做任何事情。我也尝试过:
LayoutParams params = layout.getLayoutParams();
params.height = 320;
params.width = 320;
但同样的问题发生了。