Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can i group controls together?

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.

like image 311
Michel Avatar asked Sep 12 '13 07:09

Michel


People also ask

What is the advantage of grouping controls on a form?

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.

How do you select more than one control at a time?

To select multiple controls simultaneouslyCTRL+click: Hold down the CTRL key while you click each control.

Which control is used to hold other controls in groups?

Answer. Answer: Windows Forms GroupBox controls are used to group other controls.


2 Answers

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
like image 91
Seraphim's Avatar answered Oct 12 '22 00:10

Seraphim's


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.

like image 27
krishan711 Avatar answered Oct 12 '22 00:10

krishan711