Reputation: 621
I have a layout wich is nested like this:
<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" >
<ScrollView
android:id="@+id/scrollAplicacoes"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" >
<TextView
android:id="@+id/titulo"
android:layout_width="match_parent"
android:layout_height="60dp"
android:fontFamily="Arial"
android:lineSpacingExtra="-5dp"
android:text="@string/titulo_aplicacao"
android:textColor="#3c3c3c"
android:textSize="25sp"
android:textStyle="bold"/>
<ImageView
android:id="@+id/btnAplicacaoUm"
android:layout_width="match_parent"
android:layout_height="150dp"
android:onClick="selectAplicacao"
android:src="@drawable/aplicacoes_item1" />
<ImageView
android:id="@+id/btnAplicacaoDois"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="10dp"
android:onClick="selectAplicacao"
android:src="@drawable/aplicacoes_item2" />
<ImageView
android:id="@+id/btnAplicacaoTres"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_marginTop="10dp"
android:onClick="selectAplicacao"
android:src="@drawable/aplicacoes_item3" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="@+id/menuFixo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@drawable/faixa_below" >
<ImageView
android:id="@+id/belowHome"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:contentDescription="@string/descBtnHome"
android:layout_marginTop="5dp"
android:src="@drawable/below_home_sel" />
<ImageView
android:id="@+id/belowCalculadora"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="abreCalculadora"
android:contentDescription="@string/descBtnCalculadora"
android:layout_marginTop="5dp"
android:src="@drawable/below_calc" />
<ImageView
android:id="@+id/belowProdutos"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/descFaixaProdutos"
android:layout_marginTop="5dp"
android:layout_weight="1"
android:src="@drawable/below_produtos" />
</LinearLayout>
</RelativeLayout>
The problem is that the LinearLayout outside the ScrollView, at the end is fixed on the bottom, and the scroll is placed behind it. So i need the Scroll to be the screen height minus this fixed LinerLayout height minus a little margin.
I tried this:
(...)
int scrollFInalHeight = scrollHeight - fixedMenuHeight - 10;
ViewGroup.LayoutParams param = new ViewGroup.LayoutParams(scrollStartWidth, scrollFInalHeight);
scroll.setLayoutParams(param);
But the app crashes when I start this activity. This java code is within the public void onWindowFocusChanged(boolean hasFocus) method.
Any suggestions? Thanks in advance! ;)
Upvotes: 1
Views: 19323
Reputation: 18454
@aNikeT's answer is correct, but it will be safer with
ViewGroup.LayoutParams layoutParams = mDescriptionScrollView.getLayoutParams();
layoutParams.height = scrollViewHeight;
Upvotes: 4
Reputation: 96
You need to set Height
scroll_view.setLayoutParams(new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
or
scroll_view.setLayoutParams(new RelativeLayout.LayoutParams(
LayoutParams.FILL_PARENT, 350));
Upvotes: 5
Reputation: 11337
Have you tried to put
android:layout_above="@+id/menuFixo"
in your ScrollView?
Upvotes: 3