I have a textview that I want to change the width to match_parent and height to remain at wrap_content. It is nested within a horizontal linearlayout. It is the 2nd in 3 textviews each of which has a weight of 1. When this particular fragment is run it sets the other two buttons to
previousButton.setVisibility(View.GONE);
nextButton.setVisibility(View.GONE);
TextView
<TextView
android:id="@+id/home"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:text="HOME"
android:layout_weight="1"
android:background="@drawable/button_selector"
android:layout_marginLeft="10dp"
android:layout_marginBottom="10dp"
android:padding="10dp"
android:gravity="center"
android:textColor="#000000"
android:textStyle="bold"
android:onClick="home"
/>
I am using the following to try to change the layout in a fragment:
homeButton.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
When I run it I get the error:
java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.LinearLayout$LayoutParams