Weird behavior in EditText - android

I'm having problems with the behavior of an EditText. Here is the thing:
When I click on the EditText the softKeyboard appears and I still can see the EditText (so I can see what I'm writing). But if I first click on a Button or if I hide the softKeyboard and click again in the EditText then the softKeyboard appears but the EditText is below the softKeyboard.
I've tried several things. My app is fullScreen but I can't find where I set it because I'm not using a custom theme and in my activity I only have this:
<activity
android:name=".Textinput"
android:label="#string/title_activity_textinput"
android:screenOrientation="portrait"
android:theme="#style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustResize|stateHidden"/>
The .xml of the activity is:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context="com.jesusortega.esloganquizz.Textinput"
tools:showIn="#layout/activity_textinput"
android:background="#171c22"
android:gravity="center_vertical"
android:orientation="vertical"
>
<ImageView
android:id="#+id/image"
android:layout_width="220dp"
android:layout_height="220dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginLeft="#dimen/activity_horizontal_margin"
android:layout_marginRight="#dimen/activity_horizontal_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"/>
<TextView
android:id="#+id/textview1"
android:layout_width="340dp"
android:layout_height="wrap_content"
android:background="#drawable/shadowbuttonblue"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="18sp"
android:gravity="left|center_vertical"
android:layout_gravity="end"
android:paddingEnd="50dp"
android:paddingRight="50dp"
android:paddingLeft="20dp"
android:paddingStart="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="-30dp"
/>
<Button
android:id="#+id/button1"
android:layout_width="340dp"
android:layout_height="40dp"
android:background="#drawable/shadowbuttongreen"
android:text="#string/string13"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="18sp"
android:gravity="right|center_vertical"
android:layout_gravity="left"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:paddingLeft="50dp"
android:layout_marginBottom="8dp"
android:layout_marginLeft="-30dp"
android:onClick="function1"
/>
<Button
android:id="#+id/button2"
android:layout_width="340dp"
android:layout_height="40dp"
android:background="#drawable/shadowbuttonyellow"
android:text="#string/string14"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="18sp"
android:gravity="left|center_vertical"
android:layout_gravity="end"
android:paddingLeft="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_marginBottom="8dp"
android:layout_marginRight="-30dp"
android:onClick="function1"
/>
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/string15"
android:textColorHint="#ffffff"
android:padding="10dp"
android:layout_marginRight="10dp"
android:layout_marginLeft="10dp"
android:layout_marginBottom="8dp"
android:background="#drawable/introducirtexto"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:textSize="18sp"
android:textColor="#ffffff"
android:textCursorDrawable="#null"
android:imeOptions="actionGo"
android:singleLine="true"/>
<Button
android:id="#+id/button3"
android:layout_width="340dp"
android:layout_height="40dp"
android:background="#drawable/shadowbuttonred"
android:text="#string/string16"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="18sp"
android:gravity="right|center_vertical"
android:layout_gravity="left"
android:paddingEnd="20dp"
android:paddingRight="20dp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:layout_marginLeft="-30dp"
android:onClick="check"
/>
</LinearLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top|right"
android:layout_margin="10dp">
<Button
android:id="#+id/esquina"
android:layout_width="70dp"
android:layout_height="40dp"
android:drawableLeft="#drawable/small_coin"
android:background="#drawable/shadowbuttonblue"
android:padding="5dp"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="22sp"
android:onClick="coins"/>
</RelativeLayout>
I know the adjustResize doesn't work in full screen but that's no important for me, I just want to see the EditText every time I click in it.
Thanks.
Edit:
This is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.untoj.app"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}

In AndroidManifest.xml for your activity add:
android:windowSoftInputMode="adjustPan|adjustResize"
Depending on what behavior you would like to implement you could use also:
android:windowSoftInputMode="adjustResize"
Here is description of both options:
"adjustResize" - The activity's main window is always resized to make room for the soft keyboard on screen.
"adjustPan" - The activity's main window is not resized to make room for the soft keyboard. Rather, the contents of the window are automatically panned so that the current focus is never obscured by the keyboard and users can always see what they are typing. This is generally less desirable than resizing, because the user may need to close the soft keyboard to get at and interact with obscured parts of the window.

I've been searching for a while (not the first time I do) and I found something I can call a "solution" thanks to Thair Jaber -> https://stackoverflow.com/a/33649590/6109180
He said that it seems to be a bug. If i remove the gravity in the EditText it works like it should.
Thanks for the help anyway.

Related

Svg not visible in device but visible in android xml

I have used SVG's for these icons, the icons are visible in xml but not visible in device .
following is my code :
` <LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10"
>
<ImageView
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="1.5"
app:srcCompat="#drawable/email_id_icon"
/>
<EditText
android:layout_width="0dp"
android:id="#+id/et_email"
android:layout_height="wrap_content"
android:layout_weight="8"
android:textColor="#fff"
android:inputType="textEmailAddress"
android:background="#android:color/transparent"
android:hint="Email Id"
android:textColorHint="#fff"
android:imeOptions="actionNext"
/>
</LinearLayout>`
I have gone through similar questions on SO, most of them suggested to use
android: src instead of app:srcCompat , but I have to use srcCompat only because of SVGs. So what should I do?
Edit -
I have done the same thing in another activity's layout .
here is the working code :
<LinearLayout
android:id="#+id/login_form_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/textView2"
android:gravity="center_horizontal"
android:orientation="vertical"
android:padding="20dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10">
<ImageView
android:id="#+id/username_iv"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="2"
app:srcCompat="#drawable/email_id_icon" />
<EditText
android:layout_width="0dp"
android:id="#+id/username_et"
android:layout_height="wrap_content"
android:layout_weight="8"
android:textColor="#fff"
android:inputType="textEmailAddress"
android:background="#android:color/transparent"
android:hint="Email Id"
android:textColorHint="#fff"
android:imeOptions="actionNext"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="10dp"
android:background="#fff" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10">
<ImageView
android:id="#+id/password_iv"
android:layout_width="0dp"
android:layout_height="25dp"
android:layout_weight="2"
app:srcCompat="#drawable/password_icon" />
<EditText
android:id="#+id/password_et"
android:layout_height="wrap_content"
android:layout_weight="8"
android:layout_width="0dp"
android:background="#android:color/transparent"
android:textColor="#fff"
android:hint="Password"
android:inputType="textPassword"
android:fontFamily="roboto"
android:textColorHint="#fff"
/>
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="20dp"
android:background="#fff" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/btn_login"
android:layout_marginBottom="20dp"
android:background="#drawable/login_button_style"
android:text="Login"
android:textSize="#dimen/headingText"
android:textAllCaps="false"
android:textColor="#fff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_forgetpassword"
android:layout_marginBottom="10dp"
android:text="Forget your password ?"
android:textColor="#fff"
android:textSize="#dimen/headingText" />
</LinearLayout>
I did not want to have icons in 4 resolutions so I made a single .png image and converted into .svg using Android Studio's Vector asset .
Make sure you are using AppCompatActivity and not Activity. If you are using Activity, then write in your activity / fragment:
imageView.setImageResource(R.drawable.ic_svg_image);
Also add in build.gradle:
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
And for 4.x versions of Android you can also add a support for TextViews' inner drawables. This is also actual for ImageViews.
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
// This flag should be set to true to enable VectorDrawable support for API < 21.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
}
}
Then in AndroidManifest add this file:
<application
android:name=".MyApplication"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
...
</application>
Sometimes it crushes on some old devices. Then wrap your drawable inside:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/ic_svg_image/>
</selector>
and set it instead of SVG:
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/drawable"
/>
Add vectorDrawables in build.gradle (app)
defaultConfig { vectorDrawables.useSupportLibrary = true }
Then use androidx.appcompat.widget.AppCompatImageView instead of ImageView.
Make sure to use android:src to specify the svg added with Vector Asset tool.
Done!
you can use VectorDrawable
Here is a tool to convert you svg to VectorDrawable
On pre lollipop device svg support is not quite comprehensive.
Add this in your build.gradle
android {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Late answer but hope it helps someone. If someone is using constraint layout as the parent, with android:layout_height="wrap_content" and if any of the inner views have android:layout_height="match_parent", then the inner view is not visible. Making the height of the inner elements to wrap content and constraining it to the top and bottom of the parent constraint layout element made it work for me.

How to solve a rendering issue with facebook loginbutton?

I am trying to implement facebook into my app. I was following the directions from the facebook developers site, but got stuck on a step which wasn't explained fully, or in my case, assumed I knew what they were talking about.
Either way, I added the facebook sdk, and did all the preliminary steps as required. However when I add the facebook loginbutton to my gameconsole.xml and try to switch it to design view in android studio I get a rendering error.
Here's my gameconsole.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/gameconsole_bg">
<ImageView
android:id="#+id/imageView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="30dp"
android:maxHeight="325dp"
android:adjustViewBounds="true"
/>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:capitalize="characters"
android:ems="10"
android:gravity="center" />
<TextView
android:id="#+id/editText2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageButton2"
android:layout_centerHorizontal="true"
android:layout_marginTop="97dp"
android:ems="5"
android:visibility="invisible"
/>
<TextView
android:id="#+id/editText3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/editText2"
android:layout_below="#+id/imageButton2"
android:ems="5"
android:visibility="invisible"
/>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageView1"
android:layout_centerHorizontal="true"
android:text="#string/pc1"
android:textSize="12sp"
android:textColor="#ffffff" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/help"
android:id="#+id/imageButton3"
android:layout_above="#+id/editText2"
android:layout_toLeftOf="#+id/editText3"
android:layout_toStartOf="#+id/editText3" />
<ImageButton
android:id="#+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/rateus"
android:layout_marginTop="60dp"
android:layout_below="#+id/editText1"
android:layout_toRightOf="#+id/editText3"
android:layout_toEndOf="#+id/editText3" />
<com.facebook.login.widget.LoginButton
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
</RelativeLayout>
I've read somewhere that facebook.sdkinitialize must be called first for the UI to work? Ok fine. I put this line of code in my application code
import android.app.Application;
import com.facebook.FacebookSdk;
import com.facebook.appevents.AppEventsLogger;
public class MyApp extends Application {
#Override
public void onCreate() {
super.onCreate();
// Initialize the SDK before executing any other operations,
FacebookSdk.sdkInitialize(getApplicationContext());
AppEventsLogger.activateApp(this);
My real question is what does this matter anyway? I'm not running the program so nothing is being initialized yet. I'm just trying to add the button in design mode BEFORE the program is run. In design mode, no program is being run, or am I wrong? I'm still new to programming and this is giving me a headache. Any help will be appreciated.
Rendering problems are usually related to your dependencies...
try to upgrade the com.android.support:appcompat-v7 like this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.0.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
and here is my facebook login button
<com.facebook.login.widget.LoginButton
android:id="#+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="30dp"
android:layout_marginBottom="30dp" />
I hope this will help!

ConstraintLayout's blueprint does not match the final design

As I have updated to Android Studio 2.2, I tried new ConstraintLayout to create a simple Activity. Surprisingly, alpha 8 (currently the most up-to-date) is really buggy, causing multiple resets in the blueprint stage.
The main problem is that all items that I have added through Blueprint are not constrained in the Design tab:
Design and Blueprint
The dependencies:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
//testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.android.support:design:24.2.1'
compile 'com.google.android.gms:play-services-appindexing:9.4.0'
compile 'org.apache.openejb:openejb-telnet:3.1.4'
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8'
}
I do remember unchecking or checking some checkmark when creating new Empty Activity. Does it have to do with that?
Activity class extends Activity.
Please help me get rid of bugs of new layout constructor.
XML:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/activity_telnet"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="xx.xxx.xxxx.TelnetActivity">
<TextView
android:text="IP:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_IP"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
<EditText
android:layout_width="180dp"
android:layout_height="16dp"
android:inputType="text|textPersonName"
android:ems="10"
android:id="#+id/et_IP"
android:layout_marginStart="80dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toRightOf="#+id/tv_IP" android:layout_marginLeft="80dp"
/>
<TextView
android:text="Port:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_port"
app:layout_constraintLeft_toLeftOf="#+id/tv_IP"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="#+id/tv_IP"/>
<EditText
android:layout_width="180dp"
android:layout_height="16dp"
android:inputType="number"
android:ems="10"
android:id="#+id/et_port"
app:layout_constraintBottom_toBottomOf="#+id/tv_port"
app:layout_constraintLeft_toLeftOf="#+id/et_IP"
/>
<Button
android:text="Connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/btn_connect"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="#+id/et_port"
app:layout_constraintLeft_toLeftOf="parent"
tools:layout_constraintRight_creator="1" tools:layout_constraintLeft_creator="1"
android:onClick="connect (TelnetActivity)"/>
<TextView
android:text="Status:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView3"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="#+id/btn_connect"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:text="Disconnected"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_status"
app:layout_constraintTop_toTopOf="#+id/textView3"
app:layout_constraintLeft_toLeftOf="#+id/et_port"/>
<TextView
android:text="Send msg:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView4"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="#+id/textView3"
app:layout_constraintLeft_toLeftOf="#+id/textView3"/>
<EditText
android:layout_height="16dp"
android:ems="10"
android:id="#+id/et_sendMsg"
android:layout_width="180dp" android:inputType="text"
app:layout_constraintBottom_toBottomOf="#+id/textView4"
app:layout_constraintRight_toRightOf="#+id/et_port"/>
<TextView
android:text="Response:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/textView5"
android:layout_marginTop="16dp" app:layout_constraintTop_toBottomOf="#+id/textView4"
app:layout_constraintLeft_toLeftOf="parent"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_response"
app:layout_constraintBottom_toBottomOf="#+id/textView5"
app:layout_constraintLeft_toLeftOf="#+id/tv_status"
app:layout_constraintTop_toTopOf="#+id/textView5"/>
<Button
android:text="OK"
android:layout_width="88dp"
android:layout_height="48dp"
android:id="#+id/btn_sendMsg"
app:layout_constraintBottom_toBottomOf="#+id/et_sendMsg"
app:layout_constraintTop_toTopOf="#+id/et_sendMsg"
android:layout_marginBottom="16dp"
android:layout_marginStart="24dp"
app:layout_constraintLeft_toRightOf="#+id/et_port" android:layout_marginLeft="24dp"
app:layout_constraintVertical_bias="0.44" android:onClick="sendMsg (TelnetActivity)"/>
</android.support.constraint.ConstraintLayout>
PS: Restarting Android Studio helped with getting all the elements on the right places, until I moved any of them. After that - everything collapses again.
If you updated from alpha7 to alpha8 (which is probably the case if you downloaded Android Studio 2.2), you may need to rebuild your project and/or do File->Invalidate Caches in Studio -- though restarting Studio should have been enough. Tell me if that works for you.
Also; on which environment are you running? (Windows, Mac, Linux, which JVM...)

How to apply Material Design Facebook button in android

I'm using compile 'com.facebook.android:facebook-android-sdk:4.7.0'
and:
<com.facebook.login.widget.LoginButton
android:id="#+id/tutorial_button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="16dp"
/>
But the button looks so ugly:
Is there any way to make it look materialized or more cooler?
I tried to mimic the Material raised button described in Google's Material Design specifications, this is what I could do :
To cover pre-lollipop versions, I used the properties of the CardView support library :
compile 'com.android.support:cardview-v7:23.1.0'
I put the LoginButton inside the CardView :
<android.support.v7.widget.CardView xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="6dp"
card_view:cardBackgroundColor="#ffd9d9d9"
card_view:cardCornerRadius="2dp"
card_view:cardElevation="6dp">
<com.facebook.login.widget.LoginButton xmlns:fb="http://schemas.android.com/apk/res-auto"
android:id="#+id/login_button"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-medium"
android:paddingBottom="12dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="12dp"
android:textAllCaps="true"
android:textColor="#android:color/white"
fb:com_facebook_login_text="log in with facebook"
fb:com_facebook_logout_text="log out from facebook" />
</android.support.v7.widget.CardView>
To remove the little f icon from the original login button, I added this to the java LoginButton instannce :
mButtonLogin.setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
I ended up setting paddings.
<com.facebook.login.widget.LoginButton
android:id="#+id/tutorial_button_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:paddingBottom="16dp"
android:paddingTop="16dp"
android:paddingRight="16dp"
android:paddingLeft="16dp"
android:layout_marginBottom="#dimen/activity_vertical"
/>

How to set position:fixed in android?

In my app, there is a login and password field near the middle of the screen. I have this in the manifest
android:windowSoftInputMode="adjustResize|stateHidden"
So that the fields are still visible when the keyboard is showing. But the problem is, there is a textview that is bottom aligned, and when the keyboard shows, this view overlaps with the login button under the username/password fields, is there a way, so set that textview field to not be affected by the adjestResize?
Thanks.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/credentailsLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/background_home"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".ActivityHome" >
<ImageView
android:id="#+id/imageLogo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/username"
android:layout_alignParentTop="true"
android:layout_marginBottom="50dp"
android:layout_marginTop="10dp"
android:scaleType="centerInside"
android:contentDescription="#+strings/logoimage"
android:src="#drawable/logo_2_scale" />
<EditText
android:id="#+id/username"
android:layout_width="480dp"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginBottom="10dp"
android:layout_centerInParent="true"
android:background="#drawable/bg_edit_text"
android:gravity="center"
android:hint="#string/login_username"
android:inputType="textEmailAddress"
android:text="#string/DEBUG_login_username"
android:textColor="#000000" >
</EditText>
<EditText
android:id="#+id/password"
android:layout_width="480dp"
android:layout_height="wrap_content"
android:layout_below="#+id/username"
android:layout_marginBottom="10dp"
android:layout_centerInParent="true"
android:background="#drawable/bg_edit_text"
android:gravity="center"
android:hint="#string/login_password"
android:inputType="textPassword"
android:text="#string/DEBUG_login_password"
android:textColor="#000000" />
<Button
android:id="#+id/logInMode"
style="#style/loginButtonStyle"
android:layout_width="480dp"
android:layout_height="43dp"
android:layout_below="#+id/password"
android:layout_centerInParent="true"
android:background="#drawable/button_selector"
android:gravity="center"
android:onClick="ValidateLogin"
android:text="#string/loginonline" />
<TextView
android:id="#+id/advancedMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_gravity="bottom"
android:background="#drawable/advmenu_button_selector"
android:clickable="true"
android:gravity="center"
android:onClick="ShowAdvancedMenu"
android:paddingBottom="3dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="2dp"
android:text="#string/advancedmenu"
android:textColor="#FFFFFF"
android:textSize="17sp" />
</RelativeLayout>
EDIT:
Apparently a member of the Android team said there is no direct way to do this. I searched for "android check if keyboard is visible" on Google and got the following answered question:
How do I Detect if Software Keyboard is Visible on Android Device?
According to the linked answer, you can detect it indirectly by checking if the window size changed in #onMeasure. See How to check visibility of software keyboard in Android?

Categories

Resources