java.lang.RuntimeException: Unable to start activity chronometer - java

I'm trying to create a chronometer, but I have a problem with the code. When I open the app on my tablet and on the emulator the app does not work, but this launches with no problem.
Please help me :(, or if you have another chronometer script available with milliseconds, please share it, as I haven't found anything else that would do what I need.
The error:
06-06 16:59:43.048 3724-3724/com.colorchronometer.rubiks E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.colorchronometer.rubiks/com.colorchronometer.rubiks.StopwatchActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
The manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.colorchronometer.rubiks" >
<application android:icon="#drawable/icon" android:label="#string/app_name">
<activity android:name=".StopwatchActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.Black.NoTitleBar"
android:configChanges="keyboardHidden|orientation"/>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</application>
</manifest>
And the xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/parentFrameLayout">
<ImageView
android:src="#drawable/bkgl"
android:scaleType="fitXY"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/backgroundImageView">
</ImageView>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/linearLayout">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:gravity="center"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:id="#+id/timerBackground"
android:background="#drawable/timerbackground.9">
<TextView
style="#style/timerText"
android:text="#string/timer"
android:id="#+id/timer">
</TextView>
<TextView
style="#style/timerText"
android:text="#string/timerMs"
android:id="#+id/timerMs"
android:textSize="30sp"
android:paddingTop="30sp">
</TextView>
</LinearLayout>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:id="#+id/scrollView">
</ScrollView>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:id="#+id/buttonArea"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ButtonstartButton- android-onClick=-startClick-
style="#style/buttonText"
android:layout_marginLeft="5dp"
android:background="#ff5cff9b"
android:textColor="#5F3A00"
android:shadowColor="#FBEBC5"
android:text="#string/startText"
android:layout_weight="0.5">
</Button>
<Button
style="#style/buttonText"
android:background="#FFFF6E75"
android:textColor="#2E2E2E"
android:shadowColor="#959597"
android:text="#string/resetText"
android:id="#+id/resetButton"
android:onClick="resetClick"
android:layout_weight="0.5">
</Button>
<Button
style="#style/buttonText"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:background="#ffff6e75"
android:textColor="#7A1100"
android:shadowColor="#DF726E"
android:text="#string/stopText"
android:id="#+id/stopButton"
android:visibility="gone"
android:onClick="stopClick"
android:layout_weight="1">
</Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</FrameLayout>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentBottom="true" >
</RelativeLayout>

Related

Android Studio app does not fit on screen

I am new to Android Studio and can't seem to fix my app not fitting on my screen. I'm using Honor 8 for testing how the app looks and works but parts don't fit. I have tried including activity_main for different screen densities and and screen sizes, but nothing seems to work. Would appreciate some help.
Can not include images yet so here is manifest and activity_main.xml.
activity_main.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
android:id="#+id/parent">
<RelativeLayout
android:id="#+id/imageRel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="5dp"
android:layout_alignParentTop="true">
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:minWidth="100dp"
android:minHeight="100dp"
android:src="#mipmap/ic_launcher" />
<Button
android:id="#+id/imgButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_toRightOf="#+id/image"
android:text="Press" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/inputRel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/imageRel"
android:layout_margin="20dp">
<EditText
android:id="#+id/nameTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:width="170dp"
android:hint="Name" />
<EditText
android:id="#+id/emailTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/nameTxt"
android:layout_margin="10dp"
android:width="170dp"
android:hint="Email" />
<EditText
android:id="#+id/passwordTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/emailTxt"
android:layout_margin="10dp"
android:width="170dp"
android:password="true"
android:hint="Password" />
<EditText
android:id="#+id/reenterTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/passwordTxt"
android:layout_margin="10dp"
android:width="170dp"
android:password="true"
android:hint="Re-Enter Password" />
<TextView
android:id="#+id/genderTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/reenterTxt"
android:layout_margin="10dp"
android:text="Gender:" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/genderTxt"
android:layout_margin="10dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/radioMale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="Male" />
<RadioButton
android:id="#+id/radioFemale"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female" />
<RadioButton
android:id="#+id/radioOther"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Other" />
</RadioGroup>
<TextView
android:id="#+id/countryTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/radioGroup"
android:layout_margin="10dp"
android:text="Country:" />
<Spinner
android:id="#+id/countrySpinner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/radioGroup"
android:layout_margin="10dp"
android:layout_toRightOf="#+id/countryTxt"
android:textColor="#000000" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/licenseRel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="10dp"
android:layout_toRightOf="#+id/inputRel"
android:layout_centerVertical="true">
<TextView
android:id="#+id/licenseTxt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/license_text" />
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/licenseCheck"
android:layout_below="#+id/licenseTxt"
android:layout_centerHorizontal="true"
android:text="I Agree" />
</RelativeLayout>
<Button
android:id="#+id/registerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Register"
android:layout_below="#id/inputRel"/>
</RelativeLayout>`
AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.RegistrationApp">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>

My android app crash due to Java.lang.RuntimeException

When I run this on my emulator or real device above android version 7, it works really fine. However,The problem starts when i tried to install it on android version 6 or 5 and below even though my minimum SDK is 4.0.1. or 15.
Last two days tried to solved it by going through different post of stackoverflow, but noting worked properly.
Here is my crash-Stack Tarces log
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2534)
at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2608)
at android.app.ActivityThread.access$800 (ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loop (Looper.java:194)
at android.app.ActivityThread.main (ActivityThread.java:5637)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)
Caused by: java.lang.RuntimeException:
at android.app.ActivityManager$TaskDescription.<init>
(ActivityManager.java:555)
at android.app.Activity.onApplyThemeResource (Activity.java:3741)
at android.view.ContextThemeWrapper.initializeTheme
(ContextThemeWrapper.java:140)
at android.view.ContextThemeWrapper.setTheme
(ContextThemeWrapper.java:85)
at android.support.v7.app.AppCompatActivity.setTheme
(AppCompatActivity.java)
at android.app.ActivityThread.performLaunchActivity
(ActivityThread.java:2474)
at android.app.ActivityThread.handleLaunchActivity
(ActivityThread.java:2608)
at android.app.ActivityThread.access$800 (ActivityThread.java:178)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
at android.os.Handler.dispatchMessage (Handler.java:111)
at android.os.Looper.loop (Looper.java:194)
at android.app.ActivityThread.main (ActivityThread.java:5637)
at java.lang.reflect.Method.invoke (Method.java)
at java.lang.reflect.Method.invoke (Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:959)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)
android manifests
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:allowBackup="true"
android:icon="#drawable/iconlarge"
android:label="#string/app_name"
android:roundIcon="#drawable/iconlarge"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".dropdown.AboutUs"></activity>
<activity android:name=".Activity.MainActivity">
<intent-filter>
[![enter image description here][1]][1]<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".viewClass" />
/>
<activity android:name=".webview.seetings.PrivacyPolicy" />
<activity android:name=".webview.seetings.TermsCondition" />
<activity android:name=".infozone" />
<activity android:name=".webview.timeadjust" />
</application>
Here is my Style.xml resource:
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/transparent</item>
<item name="colorPrimaryDark">#color/black</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay"
parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay"
parent="ThemeOverlay.AppCompat.Light"/>
<style name="TextAppearance.AppCompat.Widget.ActionBar.Title"
parent="#android:style/TextAppearance">
<item name="android:textSize">20sp</item>
<item name="android:textColor">#color/black</item>
</style>
Main Activity Layout
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_marginTop="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:gravity="center"
android:padding="1dp"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Land1"
android:layout_margin="14dp"
android:text="#string/LandTime"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/liteblue"
android:background="#drawable/border"
android:padding="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Land2"
android:layout_margin="14dp"
android:text="#string/LandDua"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/liteblue"
android:background="#drawable/border"
android:padding="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Land3"
android:layout_margin="14dp"
android:text="#string/LandOju"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/liteblue"
android:background="#drawable/border"
android:padding="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Land4"
android:layout_margin="14dp"
android:text="#string/LandKoron"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/liteblue"
android:background="#drawable/border"
android:padding="10dp"/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/Land5"
android:layout_margin="14dp"
android:text="#string/LandHadis"
android:textAllCaps="false"
android:textAlignment="center"
android:textSize="15sp"
android:textStyle="bold"
android:textColor="#color/liteblue"
android:background="#drawable/border"
android:padding="10dp"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_marginBottom="50dp"
android:orientation="horizontal"
android:weightSum="9"
>
<Button
android:id="#+id/share"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:layout_weight="3"
android:background="#color/coloraqua"
android:drawableLeft="#drawable/share"
android:text="Share"
android:textAllCaps="false"
/>
<Button
android:id="#+id/rate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:layout_weight="3"
android:background="#color/coloraqua"
android:drawableLeft="#drawable/rating"
android:shadowColor="#color/colorAccent"
android:text="Rate"
android:textAllCaps="false" />
<Button
android:id="#+id/info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_marginTop="3dp"
android:layout_marginRight="3dp"
android:layout_weight="3"
android:background="#color/coloraqua"
android:drawableLeft="#drawable/infoa"
android:text="Info"
android:textAllCaps="false" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="horizontal"
android:weightSum="9">
</LinearLayout>
</LinearLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-2863417604404784/6151426605">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
</android.support.v7.widget.CardView>
View class for recycler Adapter
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:background="#drawable/border"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_margin="5dp"
android:background="#color/white"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ddddddddd"
android:textStyle="bold"
android:textSize="20sp"
android:id="#+id/title"
android:padding="10dp"
android:textColor="#color/black"/>
</LinearLayout>
</RelativeLayout>
viewclass for recycler adapter
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
<android.support.v7.widget.RecyclerView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/recycle"
android:layout_gravity="center"
>
</android.support.v7.widget.RecyclerView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/banner">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
webview layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context=".Activity.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="58dp">
<WebView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/webView"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
</LinearLayout>
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
ads:adSize="BANNER"
ads:adUnitId="#string/O3">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
one additional error log
1. java.lang.RuntimeException:
2. at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2534)
3. at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2608)
4. at android.app.ActivityThread.access$800 (ActivityThread.java:178)
5. at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1470)
6. at android.os.Handler.dispatchMessage (Handler.java:111)
7. at android.os.Looper.loop (Looper.java:194)
8. at android.app.ActivityThread.main (ActivityThread.java:5637)
9. at java.lang.reflect.Method.invoke (Native Method)
11. at java.lang.reflect.Method.invoke (Method.java:372)
12. at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:959)
13. at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:754)
Caused by: java.lang.RuntimeException:
14. at android.app.ActivityManager$TaskDescription.<init> (ActivityManager.java:555)
15. at android.app.Activity.onApplyThemeResource (Activity.java:3741)
16. at android.view.ContextThemeWrapper.initializeTheme (ContextThemeWrapper.java:140)
17. at android.view.ContextThemeWrapper.setTheme (ContextThemeWrapper.java:85)
18. at a.b.h.a.m.setTheme(:0)
19. at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2474)

Fix a layout above soft keyboard

I know this question has been on the internet for ages, but nothing seems to work in my case.
What's wrong
As seen in screenshots, the layout having the spinner is not pushed up and is overlapped by the soft keyboard. I want this layout to be placed just above the keyboard when it pops up.
My layout file
<?xml version="1.0" encoding="utf-8"?>
<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"
android:background="#android:color/white"
android:orientation="vertical"
tools:context="believe.cht.speak.MainActivity">
<ImageView
android:id="#+id/logo"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:src="#drawable/ic_bubble"
android:tint="#color/blue" />
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:gravity="top|start"
android:hint="Start typing..."
android:padding="8dp" />
<ImageView
android:id="#+id/shadow"
android:layout_width="match_parent"
android:layout_height="6dp"
android:src="#drawable/shadow" />
<RelativeLayout
android:id="#+id/spinnerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/blue">
<Spinner
android:id="#+id/spinner"
android:layout_width="200dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
What I've tried
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustPan" //in the manifest, also tried combining the two
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN); //in the activity
<item name="android:windowActionBarOverlay">true</item> //in styles.xml
Try this
<?xml version="1.0" encoding="utf-8"?>
<ScrollView 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"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/white"
android:orientation="vertical">
<ImageView
android:id="#+id/logo"
android:layout_width="64dp"
android:layout_height="64dp"
android:layout_gravity="center_horizontal"
android:layout_margin="16dp"
android:src="#drawable/ic_message" />
<EditText
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#android:color/transparent"
android:gravity="top|start"
android:hint="Start typing..."
android:padding="8dp" />
<ImageView
android:id="#+id/shadow"
android:layout_width="match_parent"
android:layout_height="6dp"
android:src="#drawable/ic_camera" />
<RelativeLayout
android:id="#+id/spinnerLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#color/colorPrimary">
<Spinner
android:id="#+id/spinner"
android:layout_width="200dp"
android:layout_height="48dp"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
Manifest file
<activity android:name=".MyActivity"
android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
OUTPUT
Adding to Nilesh's answer above, even though the code worked, it didn't work with my Java class. The reason was that I was hiding the statusbar with
requestWindowFeature(Window.FEATURE_NO_TITLE);
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
Using the code provided and leaving the statusbar untouched did the job. Don't know why. I would be helpful if anyone could explain this.
Try using a RelativeLayout instead of LinearLayout and add android:alignParentBottom="true" to your spinnerLayout

screen isn't scrolling up when the keyboard appers

screen isn't scrolling up when the keyboard appers. I've read many answers saying to use android:windowSoftInputMode="something" I tried many of them
android:windowSoftInputMode="adjustPan|adjustResize"
android:windowSoftInputMode="adjustResize"
android:windowSoftInputMode="adjustPan"
android:windowSoftInputMode="stateVisible|adjustResize"
android:windowSoftInputMode="stateVisible"
(also tried some others) none of them worked
I think the problem is on my xml which the most was generated by android studio "activity login" template.
is there any other way to do it?
my xml file
<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"
android:gravity="center_horizontal"
android:orientation="vertical"
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="com.example.eduardo.academia.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ImageView
android:id="#+id/imageView"
android:layout_width="211dp"
android:layout_height="235dp"
app:srcCompat="#drawable/logo"
android:windowSoftInputMode="stateHidden"/>
<LinearLayout
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/action_sign_in"
android:textStyle="bold" />
<TextView
android:id="#+id/txtMudarSenha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center"
android:text="#string/forgot_password"
android:onClick="mudarSenha"
android:clickable="true"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
android manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.eduardo.academia">
<!-- To auto-complete the email text field in the login form with the user's emails -->
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.READ_PROFILE" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity
android:windowSoftInputMode="stateVisible|adjustResize"
android:name=".LoginActivity"
android:label="#string/title_activity_login"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ExerciciosActivity"
android:label="#string/title_activity_exercicios"
android:theme="#style/AppTheme.NoActionBar"></activity>
</application>
</manifest>
You should use a ScrollView for this. try below xml for your layout
<ScrollView 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"
android:fillViewport="true">
<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"
android:gravity="center_horizontal"
android:orientation="vertical"
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="com.example.eduardo.academia.LoginActivity">
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:visibility="gone" />
<ImageView
android:id="#+id/imageView"
android:layout_width="211dp"
android:layout_height="235dp"
app:srcCompat="#drawable/logo"
android:windowSoftInputMode="stateHidden"/>
<LinearLayout
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/email_login_form"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<AutoCompleteTextView
android:id="#+id/email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_email"
android:inputType="textEmailAddress"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/prompt_password"
android:imeActionId="#+id/login"
android:imeActionLabel="#string/action_sign_in_short"
android:imeOptions="actionUnspecified"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="#+id/email_sign_in_button"
style="?android:textAppearanceSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:text="#string/action_sign_in"
android:textStyle="bold" />
<TextView
android:id="#+id/txtMudarSenha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center"
android:text="#string/forgot_password"
android:onClick="mudarSenha"
android:clickable="true"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>

EditText in Android not working/allowing to enter value

My EditText element is displaying well in popup window but its not allowing to enter values,I cant type anything inside that edittext element.
here i have attached xml code and screenshot.if you want my main activity class java code too let me know i can add it here.
xml code :
`<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#android:color/background_light">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="1dp"
android:background="#android:color/darker_gray">
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_margin="20dp">
<TextView
android:id="#+id/texttitle1"
android:textStyle="bold"
android:textSize="25dp"
android:textColor="#891800"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Create Appoinment" />
<TimePicker
android:id="#+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner" />
<EditText
android:id="#+id/Easy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions"
/>
<Button
android:id="#+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="openNewActivity"
android:text="Save" />
<Button
android:id="#+id/dismiss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back to Menu" />
</LinearLayout>
</LinearLayout>
</LinearLayout>`
take the input type text noSuggestions and replace it with text
Find the solution:
1.In Manifest file please write windowSoftInputMode :
<activity android:name=".MainActivity"
android:windowSoftInputMode="stateHidden" />
Please put these lines in main LinearLayout
android:focusable="true"
android:focusableInTouchMode="true"
3.Please check the document
https://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
Try with below XML :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#android:color/background_light"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="1dp"
android:background="#android:color/darker_gray"
android:orientation="vertical"
android:padding="20dp">
>
<TextView
android:id="#+id/texttitle1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Create Appoinment"
android:textColor="#891800"
android:textSize="25dp"
android:textStyle="bold" />
<TimePicker
android:id="#+id/timePicker1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:timePickerMode="spinner" />
<EditText
android:id="#+id/Easy"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions" />
<Button
android:id="#+id/save"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:onClick="openNewActivity"
android:text="Save" />
<Button
android:id="#+id/dismiss"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Back to Menu" />
</LinearLayout>
</LinearLayout>
In my case, i had accidentally put android:descendantFocusability="blocksDescendants" to the parent layout,which blocks widgets inside this layout focusing. That is why, it was not working :)
If you have this line, please remove and it will work just fine

Categories