0

Xml Code:

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/trip2"
                android:orientation="vertical">
                <com.cengalabs.flatui.views.FlatTextView
                    android:id="@+id/Rpickdtetx"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Return Pick Up Date"
                    />
                <com.cengalabs.flatui.views.FlatEditText
                    android:id="@+id/Rpickdte"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dip"
                    android:maxLines="1"

                    android:textSize="15dp" />
            </LinearLayout>
        </RelativeLayout>
        <!--Return Pick up time-->
        <RelativeLayout

            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:orientation="vertical">
                <com.cengalabs.flatui.views.FlatTextView
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:text="Return Pick Up Time"
                    android:textSize="15dp"
                    flatui:fl_theme="@array/grass"
                    android:layout_marginLeft="10dp"
                    android:layout_marginRight="10dp"
                    android:layout_marginTop="10dp" />
                <com.cengalabs.flatui.views.FlatEditText
                    android:id="@+id/Rpicktme"
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_margin="10dip"
                    android:maxLines="1"
                    android:gravity="center_vertical"
                    android:hint="Pick-Up Time"
                    android:includeFontPadding="true"
                    android:drawableLeft="@drawable/time"
                    flatui:fl_fieldStyle="fl_box"
                  />
            </LinearLayout>
        </RelativeLayout>

.java code

  Triptype.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                switch (checkedId) {
                    case R.id.triptype1:
                        view.findViewById(R.id.trip2).setVisibility(View.INVISIBLE);
                       view.findViewById(R.id.trip21).setVisibility(View.INVISIBLE);
                       /* view.findViewById(R.id.Rpickdte).setVisibility(View.INVISIBLE);
                        view.findViewById(R.id.Rpickdtetx).setVisibility(View.INVISIBLE);*/
                        break;
                    case R.id.triptype2:
                        ReturnTrip(view);
                        break;

                }
            }
        });

I am newbie to android,I am using radio button on toggling,have to add some text boxes(above xml code of text boxes),My query making visible/invisible text box even though i wrap_content, can see a empty space.Can anyone help me how to resolve that.

Antict
  • 597
  • 5
  • 22
Kishore Kumar
  • 616
  • 5
  • 3

2 Answers2

2
 view.findViewById(R.id.trip2).setVisibility(View.GONE);
                                view.findViewById(R.id.trip21).setVisibility(View.GONE);
                   /*            view.findViewById(R.id.Rpickdte).setVisibility(View.GONE);
                             view.findViewById(R.id.Rpickdtetx).setVisibility(View.GONE);*/
                    break;   

set them to "Gone" instead of "invisible" will help to retain space

Vivek Khare
  • 162
  • 4
1

Try to use View.GONE instead of View.INVISIBLE.

The documentation says:

View.GONE: This view is invisible, and it doesn't take any space for layout purposes.

View.INVISIBLE: This view is invisible, but it still takes up space for layout purposes.

If you want to know more, you can look at this question.

Community
  • 1
  • 1
Antict
  • 597
  • 5
  • 22