Reconstructing Layout for Newly Visible Components




if(v.getId()==keyboard.getId())
{
//DisplayMetrics displaymetrics = new DisplayMetrics();
//getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
//int width = displaymetrics.widthPixels;
//int editTextWidth = width*(2/3);
//int sendTextWidth = width*(1/3);
keyboard.setVisibility(View.GONE);
a.setVisibility(View.GONE);
b.setVisibility(View.GONE);
c.setVisibility(View.GONE);

editText.setVisibility(View.VISIBLE);
//editText.setWidth(editTextWidth);
send.setVisibility(View.VISIBLE);
//send.setWidth(sendTextWidth);
}


Hello. For my main page layout, I have a few buttons displayed on my page, and one of the buttons is called keyboard. Once I click on the keyboard button, all the buttons will then be "invisible". Then an editText and a submit button will be "visible". (So, the user can input something using the on-screen keyboard, then submit the input). That's what the above code shows.


I'm currently having trouble constructing the layout of the newly visible components.


This is the xml code of the editText and submit button:



<EditText
android:id="@+id/editText"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_weight="0"
android:inputType="textMultiLine|textNoSuggestions" />


<Button
android:id="@+id/send"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:onClick="speak"
android:text="@string/sendCommand" />


As you can see, I just set the width of the components to zero, so it won't interfere with the layout visible buttons initially on the app start up. My question is how do you set the dimension and location of the newly components that are just set to visible? Also take a look at my commented out code.


No comments:

Post a Comment