Reputation: 7527
I am developing an application and sharing a layout with multiple activity. In that layout i have 5 TextViews(and showing em as button) horizontally adjacent to each other now my problem is in some activity i dont need 1 or two TextView and i want the remaining textview to take full screen width of the layout by resizing itself.and these textviews are inside a linear layout.
here is the layout code.
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:layout_margin="2dip"
android:orientation="horizontal" >
<TextView
android:id="@+id/category"
android:layout_width="wrap_content"
android:layout_height="27dip"
android:layout_marginRight="6dip"
android:background="@drawable/button_an"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="Explore by Category"
android:textColor="#000000"
android:textSize="9dip" />
<TextView
android:id="@+id/location"
android:layout_width="wrap_content"
android:layout_height="27dip"
android:layout_marginRight="6dip"
android:background="@drawable/button_an"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="Search by Location"
android:textColor="#000000"
android:textSize="9dip" />
<TextView
android:id="@+id/date"
android:layout_width="35dip"
android:layout_height="27dip"
android:layout_marginRight="6dip"
android:background="@drawable/button_an"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="Date"
android:textColor="#000000"
android:textSize="9dip" />
<TextView
android:id="@+id/mylocation"
android:layout_width="wrap_content"
android:layout_height="27dip"
android:layout_marginRight="6dip"
android:background="@drawable/button_an"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="My Location"
android:textColor="#000000"
android:textSize="9dip" />
<TextView
android:id="@+id/namesearch"
android:layout_width="wrap_content"
android:layout_height="27dip"
android:background="@drawable/button_an"
android:gravity="center_horizontal|center_vertical"
android:paddingBottom="2dip"
android:paddingLeft="5dip"
android:paddingRight="5dip"
android:paddingTop="2dip"
android:text="Search by Name"
android:textColor="#000000"
android:textSize="9dip" />
</LinearLayout>
Thanks in advance for any help.
Upvotes: 0
Views: 1574
Reputation:
Try to distribute equal weight to each of your textviews that will come out fine.
Upvotes: 3
Reputation: 46856
In your activity you can get references to your TextViews with findViewById(R.id.yourTxt);
then on the ones that you don't need you can call
txtView.setVisibility(View.GONE);
That will make them invisible, and make the space they would take up not be taken into consideration when drawing the Views.
Upvotes: 1