I have footer bar in my activity. I used fragment for footer bar. here is screen shot. . When I add the text into the EditText, the keyboard show like this. . I would like to hide the footer when the keyboard appear. I used android:windowSoftInputMode="adjustPan" in activity. I would like to know any suggestion.
Thanks.
i have faced same situation, and dont have finded any solution,so just started another activity on touch of textview. on completion of activity again in this activity gotted result back from the textview of next activity and placed the text in current activity's textview. it works
i got the same problem i just removed android:windowSoftInputMode="adjustPan" from my manifest file and i got the desired output
var originalHeight = document.documentElement.clientHeight;
var originalWidth = document.documentElement.clientWidth;
$(window).resize(function() {
// Control landscape/portrait mode switch
if (document.documentElement.clientHeight == originalWidth &&
document.documentElement.clientWidth == originalHeight) {
originalHeight = document.documentElement.clientHeight;
originalWidth = document.documentElement.clientWidth;
}`enter code here`
// Check if the available height is smaller (keyboard is shown) so we hide the footer.
if (document.documentElement.clientHeight < originalHeight) {
$('.footer').hide();
} else {
$('.footer').show();
}
});
try this it will work and give class="footer"
Related
In my game, when a textfield is touched, the view moves up along with the keyboard.
Here's the code in AndroidLauncher:
onCreate(){
//other codes...
setListenerToRootView()
}
private fun setListenerToRootView() {
val activityRootView: View = window.decorView.findViewById(content)
activityRootView.viewTreeObserver.addOnGlobalLayoutListener(keyboardLayoutListener)
}
private var keyboardLayoutListener: OnGlobalLayoutListener? = OnGlobalLayoutListener {
val visibleDisplayFrame = Rect()
window.decorView.getWindowVisibleDisplayFrame(visibleDisplayFrame)
sizeChanged(visibleDisplayFrame.width(), visibleDisplayFrame.height())
}
override fun sizeChanged(width: Int, height: Int) {
val heightRatio = Gdx.graphics.height / main.worldHeight
val worldHeightChanged = height / heightRatio
val keyboardStatus = if (height == Gdx.graphics.height) KeyboardStatus.HIDE else KeyboardStatus.SHOW
main.platformsObservable.notifyObservers(Triple(ObservableKeys.SCREEN_SIZE_CHANGED, keyboardStatus, worldHeightChanged))
log.error("SCREEN_SIZE_CHANGED, status = $keyboardStatus")
}
The above code gets the keyboard height and status to send to my libgdx game class for the Camera to move the screen up/down.
With a normal keyboard it would send something like this for when the keyboard is shown:
SCREEN_SIZE_CHANGED, status = SHOW
and when the keyboard is hidden:
SCREEN_SIZE_CHANGED, status = HIDE
But on Samsung devices with the keyboard id of "com.samsung.android.honeyboard/.service.HoneyBoardService" then it does all this when the keyboard is shown once:
SCREEN_SIZE_CHANGED, status = HIDE
SCREEN_SIZE_CHANGED, status = SHOW
SCREEN_SIZE_CHANGED, status = SHOW
SCREEN_SIZE_CHANGED, status = SHOW
And this is making the keyboard blocking the textfield in my game because the view doesn't move up.
My gdxVersion is 1.11.0
How can I fix this?
Hi This isn't a libGDX issue. You need to provide parameters to your activity specifically saying what you want for this value (being the screen keyboard as opposed to a hardware one)
android:windowSoftInputMode
as described here
https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
and consider what you want for the parameters
adjustResize
adjustPan
I'm working on App which get the data from GCM , After this I display the data in the listview and when get new data from GCM , I add these new data to the listview and I used this code
public void updateListView2(List<FeedItem> newItems) {
for(FeedItem item : newItems)
{
//Toast.makeText(this, "Title : "+item.getTitle(), Toast.LENGTH_LONG).show();
// this to add the new items at the top of the list
listAdapter.insert(item, 0);
}
// to retain the position of the listview after updated
int lastViewIndex = listView.getFirstVisiblePosition();
View view = listView.getChildAt(0);
int top = (view == null) ? 0 : view.getTop() ;
listView.setSelectionFromTop(lastViewIndex, top);
listAdapter.notifyDataSetChanged();
//this to add the button programitcally like "New Stories"
Button updateBt = new Button(this);
updateBt.setText("Updated");
feedLayout.addView(updateBt);
}
but when I tried to add the button like this "New Stories" I failed , Nothing is viewed !! so can anyone Help Me .
I would play with visibility (VISIBLE && GONE). When you get info you don't have to add the button but make it visible and with visibility GONE after clicking it (or whatever the event you want).
This may make you easier to work with hierarchies of views because you define the button in your xml layout (with visibility gone by default, at the top or in the position you need it) and change its properties dinnamically.
The best way to do is add that button and place it wherever you want in your xml layout file and set
android:visibility="gone"
or
android:visibility="invisible"
when you need the button to display, display it from java code like this
myButton.setVisibility(View.VISIBLE);
follow this, you'll get no issues.
Having Problem with Edittext and SoftKeyboard.
now if i click on edittext(hello text) to modify it (means when it gains focus bottom gridview is poping up see second image)
so how to change this behaviour of poping up the bottom views?
Any Help will be greately appreciated.
Thanks in advance.
you can open dialog and in dialog add EditText and on ok button you can change that text according to text added in dialog edittext.
android:windowSoftInputMode="adjustResize" property might be squeezing your background
use android:windowSoftInputMode="stateVisible|adjustPan" instead.
View activityRootView;
activityRootView = (LinearLayout) findViewById(R.id.root); // main layout id
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView()
.getHeight() - activityRootView.getHeight();
if (heightDiff > 100) {
// if more than 100 pixels, its
// hide your below layout like layout1.setVisibility(View.GONE);
} else {
// visible your below layout like layout1.setVisibility(View.VISIBLE);
}
}
});
Problem is shown in picture , please go light on me , i'm not that experienced in android
but trying my best to do so...
Tried this in my Main.java:
package com.faisal.my_calculator;
import android.content.SharedPreferences;
// all remaining imports here.
public class Main extends ActionBarActivity implements View.OnClickListener {
// Buttons
Button btnOne, btnTwo, btnThree, btnFour, btnFive, btnSix, btnSeven,..., btnTan, btnExit;
case R.id.three:
if (y != 0) {
y = 0;
etDisp.setText("");
}
str = str.append(btnThree.getText());
etDisp.setText(str);
break;
.
.
.
.
case R.id.add:
if (TextUtils.isEmpty(etDisp.getText().toString())) {
return;
}
operator = "+";
if (x == 0) {
x = Double.parseDouble(etDisp.getText().toString());
etDisp.setText("");
} else if (y != 0) {
y = 0;
etDisp.setText("");
} else {
y = Double.parseDouble(etDisp.getText().toString());
etDisp.setText("");
x = x + y;
etDisp.setText(Double.toString(x));
}
break;
I tried for:
appconfigchanges solution = it is not even in my AndroidManifest.xml,
Now to the layout part : In emulator all things are fully spaced on screen but when i run app below(2nd screen comes as a result not like on Emulator which i worked hard and adjusted its full screen) more when i run it on my LG_OG in landscape only starting three rows come on the screen o.O ....? need help here as well ...!
If anything needed more i will post it....!(now almost all code i have posted) Again, be patient to your brother :)
Please don't handle any exception if it is not realy needed to handle. Remove your try catch while initializing the UI and setting clicklistener to buttons and check where your code is failing.
Second you don't need to handle UI changes on orientation change as it will be handled by android itself. This will be done like -on orientation change your activity will be recreated and your oncreate will be again called so set layout and initialize all the UI element in oncrete itself and remove unnecessary code from onConfigurationChanged method.
Always check for the null value in suspected code
if(btnDiv == null)
{
//condition
}
Add following code just before try
if(btnDiv == null)
{
throw new NullPointerException("Button are not initialized");
}
if exception is thrown then your buttons are not initialized.
Yes , what a pain it was , as debugger is the best friend of programmer , i debugged it and it directly took me to the buttons which i didn't make in Landscape but were present in portrait so Eclipse doesn't like this and was causing my different buttons to stay idle but after putting those buttons in landscape xml now everything works all awesome...!
Now just layout make-up is remained as two buttons are running here and there when i run it.! :p
Thanks guys for your time...!
I have a layout in which I have autoComplete edit text with some suggestions.
The image below is its normal behaviour until keyboard slides in.
after the keyboard comes the dropdown goes above the field which hides my TO: field. As shown below.
What should I do to get the dropdown below even when the keyboard slides up.
I want the result to be like this.
Thanks...
I resolved this by hiding the upper layout when key board is shown and focus is on this edit text. As soon as the keyboard is slided_out the upper layout is visible again which bring back the original screen.
For detecting the keyboard slide_in/slide_out i used something like this.
final View activityRootView = findViewById(R.id.activityRoot);
activityRootView.getViewTreeObserver().addOnGlobalLayoutListener(
new OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
int heightDiff = activityRootView.getRootView()
.getHeight() - activityRootView.getHeight();
if (heightDiff > 100) { // if more than 100 pixels, its
// probably a keyboard...
if (searchText.isFocused()) {
//keyboard is shown
}
} else {
if (searchText.isFocused()) {
//Keyboard is hidden.
}
}
}
});