<HorizontalScrollView
android:id="@+id/horizontalScrollView1"
android:layout_width="match_parent"
android:layout_height="0dp"
android:fillViewport="true"
android:layout_weight="19" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/layoutScrollContainer"
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="@drawable/card_background" >
<
.
.
.
.
.
.
/>
</LinearLayout>
</LinearLayout>
</HorizontalScrollView>
I want to get the width of the HorizontalScrollView1
and set it to the LinearLayout
(layoutScrollContainer
)
This is my code in java but my app crashes , and I cant understand why . If you know how to do this with xml please tell me.
HorizontalScrollView scrollView = (HorizontalScrollView) findViewById (R.id.horizontalScrollView1);
LinearLayout lrLayout = (LinearLayout ) findViewById (R.id.layoutScrollContainer);
int width = scrollView.getMeasuredWidth();
lrLayout.setLayoutParams(new LinearLayout.LayoutParams(width, LinearLayout.LayoutParams.MATCH_PARENT));