I want to group some TextView
together, to show/hide them together.
Preferably that the space in the view is available for other controls which are placed below the grouped textviews
How can I do that?
p.s.:
In .Net i would use a Panel
or a Groupbox
.
Overview. Grouping related form controls makes forms more understandable for all users, as related controls are easier to identify. It also makes it easier for people to focus on smaller and more manageable groups rather than try to grasp the entire form at once.
To select multiple controls simultaneouslyCTRL+click: Hold down the CTRL key while you click each control.
Answer. Answer: Windows Forms GroupBox controls are used to group other controls.
Use a LinearLayout
(or other ViewGroup
like RelativeLayout
) and put TextView
(and other component) inside it:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="visible">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
From code
LinearLayout container = (LinearLayout) findViewById(R.id.container);
container.setVisibility(View.VISIBLE); //to show it
or
container.setVisibility(View.GONE); //to hide it
You should wrap your TextViews in a ViewGroup (like FrameLayout). Then you can put other views below / above this ViewGroup, and show/hide the ViewGroup so all the Views inside it will be shown/hidden.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With