I’m trying to put some data into a bundle and transfer it to a fragment. But the log show me an error of NullPointerException in the fragment and I don't know what is the relation between the two.
The error code :
09-22 14:19:03.216 1918-1918/com.example.user.unchained E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.example.user.unchained, PID: 1918
java.lang.NullPointerException
at com.example.user.unchained.HeaderFragement.onCreate(HeaderFragement.java:85)
at android.support.v4.app.Fragment.performCreate(Fragment.java:1481)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:908)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1121)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1484)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:450)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
The Fragment code :
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
name = (TextView) getView().findViewById(R.id.nameH);
img = (ImageView) getView().findViewById(R.id.imageViewHeader);
Bundle infos = getArguments();
name.setText(infos.getString("Name"));
img.setImageBitmap(getBitmapFromURL(infos.getString("ImgUrl")));
//Name.setText(Name.getText()+" "+infos.getString("Name"));
}
The Activity in which i put data in the bundle.
protected void onPostExecute(final String res) {
//LoginTask = null;
//showProgress(false);
try {
jObj = new JSONObject(res);
} catch (JSONException e) {
e.printStackTrace();
}
try {
if (jObj.getString("code").equals("1")) {
infos = new Bundle();
infos.putString("ID",jObj.getString("ID"));
infos.putString("Name",jObj.getString("display_name"));
infos.putString("ImgUrl","http://unchained-network.com/uploads/profilpics/53f5c570b6ac2.png");
android.support.v4.app.FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
HeaderFragement hf = new HeaderFragement();
//Charger les infos dans l'activité
hf.setArguments(infos);
tr.replace(R.id.frgmnt, hf);
tr.commit();
Intent myIntent = new Intent(getActivity(), HomesActivity.class);
//Lançer l'activité
startActivityForResult(myIntent, 0);
} else {
//password.setError(getString(R.string.error_incorrect_password));
//password.requestFocus();
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Error !");
builder.setMessage("The information entered is incorrect.\nPlease try again!")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
The layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical" >
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:visibility="gone"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/logo"
android:focusableInTouchMode="true"
android:src="#drawable/unchained_beta_logo"
android:layout_marginTop="20dp"
android:gravity="center"
android:contentDescription="Unchained-Network Logo"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
style="#style/SignInEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:completionThreshold="1"
android:inputType="textEmailAddress"
android:layout_marginTop="64dp"
android:layout_below="#+id/logo"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/email"
android:hint="Email" />
<EditText
style="#style/SignInEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:completionThreshold="1"
android:inputType="textPassword"
android:layout_marginTop="20dp"
android:layout_below="#+id/email"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/password"
android:hint="Password" />
<Button
android:id="#+id/connexion"
style="#style/ShadowText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:layout_below="#+id/password"
android:background="#color/green_android"
android:gravity="center"
android:padding="10dp"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
android:text="Go Ride !"
/>
<TextView
android:layout_width="200dp"
android:id="#+id/passf"
style="#style/ShadowText"
android:layout_height="30dp"
android:layout_marginLeft="70dp"
android:text="Forgotten your password?"
android:layout_marginTop="20dp"
android:gravity="center"
android:textSize="10sp"
android:textStyle="bold"
android:textColor="#feed01" />
<TextView
android:layout_width="200dp"
style="#style/ShadowText"
android:layout_height="30dp"
android:layout_marginLeft="70dp"
android:text="No account yet ? Get one "
android:layout_marginTop="5dp"
android:gravity="center"
android:id="#+id/newaccount"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#fff" />
</LinearLayout>
</ScrollView>
</LinearLayout>
onCreate() is too early to call getView() and it will return null. Postpone the code that needs to touch the fragment's view hierarchy to onCreateView() or later in the fragment lifecycle.
you should add your fragment container inside your main layout. then you will do that replacement using this layout
<LinearLayout
android:id="#+id/frgmnt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
change your layout with this
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical" >
<!-- Login progress -->
<ProgressBar
android:id="#+id/login_progress"
style="?android:attr/progressBarStyleLarge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:visibility="gone"/>
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" >
<LinearLayout
android:id="#+id/login_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="10dp"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingTop="5dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/logo"
android:focusableInTouchMode="true"
android:src="#drawable/unchained_beta_logo"
android:layout_marginTop="20dp"
android:gravity="center"
android:contentDescription="Unchained-Network Logo"
android:layout_alignParentTop="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<EditText
style="#style/SignInEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:completionThreshold="1"
android:inputType="textEmailAddress"
android:layout_marginTop="64dp"
android:layout_below="#+id/logo"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/email"
android:hint="Email" />
<EditText
style="#style/SignInEditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:completionThreshold="1"
android:inputType="textPassword"
android:layout_marginTop="20dp"
android:layout_below="#+id/email"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:id="#+id/password"
android:hint="Password" />
<Button
android:id="#+id/connexion"
style="#style/ShadowText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="50dp"
android:layout_below="#+id/password"
android:background="#color/green_android"
android:gravity="center"
android:padding="10dp"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
android:text="Go Ride !"
/>
<TextView
android:layout_width="200dp"
android:id="#+id/passf"
style="#style/ShadowText"
android:layout_height="30dp"
android:layout_marginLeft="70dp"
android:text="Forgotten your password?"
android:layout_marginTop="20dp"
android:gravity="center"
android:textSize="10sp"
android:textStyle="bold"
android:textColor="#feed01" />
<TextView
android:layout_width="200dp"
style="#style/ShadowText"
android:layout_height="30dp"
android:layout_marginLeft="70dp"
android:text="No account yet ? Get one "
android:layout_marginTop="5dp"
android:gravity="center"
android:id="#+id/newaccount"
android:textSize="14sp"
android:textStyle="bold"
android:textColor="#fff" />
</LinearLayout>
</ScrollView>
<LinearLayout
android:id="#+id/frgmnt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" />
</LinearLayout>
Related
Although I used the "replace" method on the piece, the second part of the piece runs on the first part It should be noted that my code is only in (main activity) and there is no code in the second fragment section (I mean the "about" fragment here) (there is a fragment class by default) so I sent it I did not
I also put a background in the xml file, but the following part works although it is not clear
Please guide me on this
Thanks
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
.
.
.
LinearLayout lnrRecyclerNoConnection, li_home, li_share, li_about, li_logout;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
replace(new HomeFragment());
...
}
.
.
.
#Override
public void onClick(View view) {
int id = view.getId();
if (id == R.id.ivMenu) {
mDrawer.openMenu(true);
} else if (id == R.id.li_home) {
replace(new HomeFragment(), "Home");
mDrawer.closeMenu(true);
} else if (id == R.id.li_about) {
replace(new AboutFragment(), "About");
mDrawer.closeMenu(true);
} else if (id == R.id.li_share) {
Toast.makeText(this, "share", Toast.LENGTH_SHORT).show();
mDrawer.closeMenu(true);
} else if (id == R.id.li_logout) {
Toast.makeText(this, "exited", Toast.LENGTH_SHORT).show();
finish();
System.exit(0);
}
}
private void replace(Fragment fragment, String string) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fl_main, fragment);
fragmentTransaction.addToBackStack(string);
fragmentTransaction.commit();
}
private void replace(Fragment fragment) {
FragmentTransaction fragmentTransaction = getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fl_main, fragment);
fragmentTransaction.commit();
}
}
This is also the XML code section
I put "Replace" in the main activity section
<?xml version="1.0" encoding="utf-8"?>
<com.mxn.soul.flowingdrawer_core.FlowingDrawer xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawerlayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
app:edPosition="2"
app:edMenuSize="260dp"
app:edMenuBackground="#F1F1F1">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_marginEnd="0dp"
android:animateLayoutChanges="true"
android:background="#color/colorBackground">
<com.google.android.material.appbar.AppBarLayout
android:id="#+id/mainAppBar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true">
<com.google.android.material.appbar.CollapsingToolbarLayout
android:id="#+id/mainCollapsingToolbar"
android:layout_width="match_parent"
android:layout_height="200dp"
android:fitsSystemWindows="true"
app:contentScrim="?attr/colorPrimary"
app:expandedTitleGravity="start|top"
app:expandedTitleMarginTop="56dp"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<RelativeLayout
android:id="#+id/mainHeader"
android:layout_width="match_parent"
android:layout_height="200dp">
<ImageView
android:id="#+id/imgChannelCover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="fitXY"
android:src="#drawable/cover_placeholder" />
<TextView
android:id="#+id/txtChannelFollower_cnt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
android:fontFamily="#font/yekan"
android:gravity="center_horizontal"
android:textColor="#color/colorPrimary"
android:textSize="16sp"
tools:ignore="NotSibling" />
<TextView
android:id="#+id/txtVideo_cnt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignStart="#+id/txtChannelFollower_cnt"
android:layout_alignEnd="#+id/txtChannelFollower_cnt"
android:layout_alignParentBottom="true"
android:layout_marginBottom="16dp"
android:fontFamily="#font/yekan"
android:gravity="center_horizontal"
android:textColor="#color/colorPrimary"
android:textSize="16sp" />
</RelativeLayout>
<androidx.appcompat.widget.Toolbar
android:id="#+id/mainToolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:paddingStart="16dp"
android:paddingEnd="16dp"
app:layout_collapseMode="pin"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
<ImageView
android:id="#+id/imgShowChannelDescription"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="start"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="16dp"
android:src="#drawable/person_outline_24" />
<ImageView
android:id="#+id/ivMenu"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="end"
android:layout_marginStart="8dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="8dp"
android:src="#drawable/menu_open_24" />
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.CollapsingToolbarLayout>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:id="#+id/lnrRecyclerNoConnection"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="vertical"
android:visibility="gone">
<pl.droidsonroids.gif.GifImageView
android:id="#+id/gifVideoLoading"
android:layout_width="150dp"
android:layout_height="150dp"
android:layout_gravity="center"
android:src="#drawable/no_connection"
android:tint="#color/colorPrimary" />
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="#font/yekan"
android:gravity="center_horizontal"
android:text="#string/noConnection" />
<Button
android:id="#+id/btnRecyclerTryConnection"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:background="#drawable/btn_selector"
android:fontFamily="#font/yekan"
android:text="refresh"
android:textColor="#color/colorWhiteTextColor"
android:textStyle="bold" />
</LinearLayout>
<com.facebook.shimmer.ShimmerFrameLayout
android:id="#+id/shimmerLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="#layout/shimmer_screen" />
<include layout="#layout/shimmer_screen" />
<include layout="#layout/shimmer_screen" />
<include layout="#layout/shimmer_screen" />
</LinearLayout>
</com.facebook.shimmer.ShimmerFrameLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/mainRecyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="16dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/CircleImageChannelProfile"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:src="#drawable/image_placeholder"
app:civ_border_color="#color/colorPrimary"
app:civ_border_width="1dp"
app:layout_anchor="#id/mainAppBar"
app:layout_anchorGravity="center_vertical|center_horizontal" />
<!--<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/CircleImageChannelProfile"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="32dp"
android:layout_marginEnd="32dp"
android:src="#drawable/image_placeholder"
app:civ_border_color="#color/colorPrimary"
app:civ_border_width="0.5dp"
app:layout_anchor="#id/mainAppBar"
app:layout_anchorGravity="bottom|end" />-->
<!--content-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/fl_main"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</RelativeLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<!--menu-->
<com.mxn.soul.flowingdrawer_core.FlowingMenuLayout
android:id="#+id/menulayout"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<FrameLayout
android:id="#+id/id_container_menu"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="200dp"
android:id="#+id/header">
<ImageView
android:id="#+id/imgChannelCoverDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#drawable/bg_card_video_main"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/colorPrimary">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/CircleImageChannelProfileDrawer"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center_horizontal|center_vertical"
android:layout_marginTop="50dp"
android:src="#drawable/image_placeholder"
app:civ_border_color="#color/colorPrimary"
app:layout_anchor="#id/mainAppBar"
app:layout_anchorGravity="center_vertical|center_horizontal"/>
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="title"
android:textSize="28sp"
android:fontFamily="#font/yekan"
android:textColor="#color/cardview_dark_background"
android:gravity="center_horizontal|center_vertical"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/li_home"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="48dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/home_24"
android:padding="4dp"
app:tint="#color/cardview_dark_background"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="home"
android:textColor="#color/cardview_dark_background"
android:fontFamily="#font/yekan"
android:textSize="16sp"
android:padding="4dp"/>
</LinearLayout>
<!--<LinearLayout
android:id="#+id/li_about"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/li_share"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="24dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/person_outline_24"
android:padding="4dp"
app:tint="#color/cardview_dark_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="about"
android:textColor="#color/cardview_dark_background"
android:fontFamily="#font/yekan"
android:textSize="16sp"
android:padding="4dp"/>
</LinearLayout>-->
<LinearLayout
android:id="#+id/li_share"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/li_home"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="24dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/share_24"
android:padding="4dp"
app:tint="#color/cardview_dark_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="اشتراک گذاری"
android:textColor="#color/cardview_dark_background"
android:fontFamily="#font/yekan"
android:textSize="16sp"
android:padding="4dp"/>
</LinearLayout>
<LinearLayout
android:id="#+id/li_logout"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layoutDirection="rtl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/li_share"
android:layout_marginHorizontal="24dp"
android:layout_marginTop="24dp" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_baseline_power_settings_new_24"
android:padding="4dp"
app:tint="#color/cardview_dark_background" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="exit"
android:textColor="#color/cardview_dark_background"
android:fontFamily="#font/yekan"
android:textSize="16sp"
android:padding="4dp"/>
</LinearLayout>
</RelativeLayout>
</com.mxn.soul.flowingdrawer_core.FlowingMenuLayout>
</com.mxn.soul.flowingdrawer_core.FlowingDrawer>
Unable to start activity Component Info ERROR
When im starting my app, its skippp all the ativity and goes at the somewhere activity and after 3 seconds it finally crashes.
its show no visible error on my java and xml...
im having error on my logcat
idont know where is the error
2019-10-16 05:55:20.542 23865-23865/com.ilsproj.ilovebatangas E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.ilsproj.ilovebatangas, PID: 23865
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ilsproj.ilovebatangas/com.ilsproj.ilovebatangas.ui.CategorySelection}: java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6521)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: java.lang.NullPointerException: Attempt to invoke interface method 'void androidx.appcompat.widget.DecorContentParent.setWindowCallback(android.view.Window$Callback)' on a null object reference
at androidx.appcompat.app.AppCompatDelegateImpl.createSubDecor(AppCompatDelegateImpl.java:753)
at androidx.appcompat.app.AppCompatDelegateImpl.ensureSubDecor(AppCompatDelegateImpl.java:659)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:552)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:161)
at com.ilsproj.ilovebatangas.ui.CategorySelection.onCreate(CategorySelection.java:20)
at android.app.Activity.performCreate(Activity.java:7051)
at android.app.Activity.performCreate(Activity.java:7042)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:169)
at android.app.ActivityThread.main(ActivityThread.java:6521)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Heres my Splashcreen.java
public class Splashsrcreen extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splashsrcreen);
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
Intent i = new Intent(Splashsrcreen.this,CategorySelection.class);
startActivity(i);
finish();
}
}, 3000);
}
}
My catergoryselection.java
public class CategorySelection extends AppCompatActivity {
CardView imagebutton;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_category_selection);
CardView mountain = findViewById(R.id.cv_mountains);
mountain.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Intent intent = new Intent( CategorySelection.this, Cat_Mountains.class);
startActivity(intent);
}
});
}
}
activity_category_selection
<?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">
<LinearLayout
android:orientation="vertical"
android:weightSum="10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#color/colorPrimary"
>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
<GridLayout
android:id="#+id/mainGrid"
android:layout_width="385dp"
android:layout_height="589dp"
android:layout_gravity="center"
android:layout_weight="8"
android:alignmentMode="alignMargins"
android:columnCount="2"
android:columnOrderPreserved="false"
android:rowCount="5"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.53999996">
<androidx.cardview.widget.CardView
android:id="#+id/cv_beaches"
android:layout_width="185dp"
android:layout_height="198dp"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="#ffff"
android:scaleType="fitCenter"
android:src="#drawable/beaches" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Beaches"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cv_mountains"
android:layout_width="185dp"
android:layout_height="198dp"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="#ffff"
android:scaleType="fitCenter"
android:src="#drawable/mountain" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Mountains"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cv_island"
android:layout_width="185dp"
android:layout_height="198dp"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="#ffff"
android:scaleType="fitCenter"
android:src="#drawable/island" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Island"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cv_churces"
android:layout_width="185dp"
android:layout_height="198dp"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="#ffff"
android:scaleType="fitCenter"
android:src="#drawable/churches" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Churches"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/cv_heritage"
android:layout_width="185dp"
android:layout_height="198dp"
android:layout_margin="5dp"
android:clickable="true"
android:focusable="true"
android:foreground="?attr/selectableItemBackground"
app:cardCornerRadius="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="155dp"
android:layout_marginStart="5dp"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:background="#ffff"
android:scaleType="fitCenter"
android:src="#drawable/heritage" />
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="10dp"
android:gravity="center"
android:text="Heritage"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</ScrollView>
This could be a caching problem.
try with:
"Android Studio: menu> Build -> Clean Project"
or
"Android Studio: menu> File -> Invalidate Caches / Restart"
Hi i am developing an app where i'm using shared element transition on textview however when i apply animation nothing happens and moreover text in other activity becomes invisible which is quite wierd i have given same transition name to both activities still i dont understand what the problem is please if someone can help me out here.
here is login activity
<?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:orientation="vertical"
tools:context="com.ct.listrtrial.activities.LoginActivity"
android:background="#color/colorPrimary">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:text="Login"
android:transitionName="#string/transition_name_signup"
android:id="#+id/text_login"
android:textColor="#color/White"
android:textSize="35sp" />
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="25dp"
android:id="#+id/login_card"
app:cardBackgroundColor="#color/White"
app:cardCornerRadius="20dp"
app:cardElevation="5dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<com.ct.listrtrial.Custom.CustomEditText
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="10dp"
android:id="#+id/text_input_email"
>
<com.ct.listrtrial.Custom.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableLeft="#drawable/message"
android:drawablePadding="10dp"
android:hint="Email id"
android:background="#android:color/transparent"/>
</com.ct.listrtrial.Custom.CustomEditText>
<View
android:id="#+id/card_divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#color/light_black"
/>
<com.ct.listrtrial.Custom.CustomEditText
android:layout_width="match_parent"
android:layout_height="80dp"
android:paddingLeft="10dp"
android:id="#+id/text_input_password"
>
<com.ct.listrtrial.Custom.TextInputEditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:drawableLeft="#drawable/lock"
android:drawablePadding="10dp"
android:hint="Password"
android:background="#android:color/transparent"/>
</com.ct.listrtrial.Custom.CustomEditText>
</LinearLayout>
</android.support.v7.widget.CardView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:text="Forgot Password?"
android:id="#+id/text_forgot_password"
android:textColor="#color/White"
android:textSize="18sp" />
</RelativeLayout>
<com.ct.listrtrial.widget.CustomButton
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="#drawable/ripple_button_effect"
android:layout_marginBottom="16dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="15dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:text="Login"
android:id="#+id/login_button"
android:textSize="20sp" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="OR CONNECT WITH"
android:textColor="#color/White"
android:textSize="15sp" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:layout_marginTop="10dp"
android:layout_marginRight="50dp"
>
<com.ct.listrtrial.Custom.GoofleCustomImageView
android:id="#+id/facebook_image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_centerInParent="true"
android:layout_marginRight="10dp"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/facebook"
/>
<com.ct.listrtrial.Custom.GoofleCustomImageView
android:id="#+id/google_image"
android:layout_width="wrap_content"
android:layout_height="45dp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/facebook_image"
android:adjustViewBounds="true"
android:scaleType="centerCrop"
android:src="#drawable/google_plus_1" />
</RelativeLayout>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<ImageView
android:id="#+id/login_page_curve"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:onClick="gotoregister"
android:src="#drawable/login_page_curve" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
android:orientation="horizontal"
>
<com.ct.listrtrial.Custom.CustomTextViewMedium
android:id="#+id/or_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="130dp"
android:text="Or"
android:layout_marginTop="10dp"
android:textColor="#color/black"
android:textSize="17sp" />
<com.ct.listrtrial.Custom.CustomTextViewBold
android:id="#+id/register_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#+id/or_text"
android:text="Register"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:textColor="#color/black"
android:textSize="17sp" />
</RelativeLayout>
</FrameLayout>
</LinearLayout>
Login activity
public class LoginActivity extends AppCompatActivity {
CustomEditText text_input_email,text_input_password;
CustomButton login_button;
GoofleCustomImageView google_image,facebook_image;
ImageView login_page_curve;
CustomTextViewMedium or_text,text_forgot_password,text_login;
CustomTextViewBold register_text;
View myView;
boolean isUp;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
initViews();
}
public void initViews(){
text_input_email = (CustomEditText)findViewById(R.id.text_input_email);
text_input_password = (CustomEditText)findViewById(R.id.text_input_password);
login_button = (CustomButton)findViewById(R.id.login_button);
google_image = (GoofleCustomImageView) findViewById(R.id.google_image);
facebook_image = (GoofleCustomImageView) findViewById(R.id.facebook_image);
login_page_curve = (ImageView)findViewById(R.id.login_page_curve);
or_text = (CustomTextViewMedium)findViewById(R.id.or_text);
text_forgot_password = (CustomTextViewMedium)findViewById(R.id.text_forgot_password);
register_text = (CustomTextViewBold)findViewById(R.id.register_text);
text_login = (CustomTextViewMedium)findViewById(R.id.text_login);
}
public void gotoregister(View view) {
Intent intent = new Intent(LoginActivity.this,RegisterActivity.class);
ActivityOptionsCompat options = ActivityOptionsCompat.makeSceneTransitionAnimation
(LoginActivity.this,login_page_curve,
getResources().getString(R.string.transition_name_signup));
startActivity(intent,options.toBundle());
overridePendingTransition(R.anim.bottom_up,R.anim.bottom_down);
finish();
}
}
before it was good without error but I dont know when I run it again and it's become error.this is a fregment activity. it close to the main activity when i open it. I already try to create a new xml and rename it but it doesn't work at all.
This is my ProfileFragment.java
public class ProfilFragment extends Fragment {
// TODO: Rename parameter arguments, choose names that match
// the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
private static final String ARG_PARAM1 = "param1";
private static final String ARG_PARAM2 = "param2";
// TODO: Rename and change types of parameters
private String mParam1;
private String mParam2;
private OnFragmentInteractionListener mListener;
public ProfilFragment() {
// Required empty public constructor
}
/**
* Use this factory method to create a new instance of
* this fragment using the provided parameters.
*
* #param param1 Parameter 1.
* #param param2 Parameter 2.
* #return A new instance of fragment ProfilFragment.
*/
// TODO: Rename and change types and number of parameters
public static ProfilFragment newInstance(String param1, String param2) {
ProfilFragment fragment = new ProfilFragment();
Bundle args = new Bundle();
args.putString(ARG_PARAM1, param1);
args.putString(ARG_PARAM2, param2);
fragment.setArguments(args);
return fragment;
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (getArguments() != null) {
mParam1 = getArguments().getString(ARG_PARAM1);
mParam2 = getArguments().getString(ARG_PARAM2);
}
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_profile, container, false);
}
// TODO: Rename method, update argument and hook method into UI event
public void onButtonPressed(Uri uri) {
if (mListener != null) {
mListener.onFragmentInteraction(uri);
}
}
#Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof OnFragmentInteractionListener) {
mListener = (OnFragmentInteractionListener) context;
} else {
}
}
#Override
public void onDetach() {
super.onDetach();
mListener = null;
}
/**
* This interface must be implemented by activities that contain this
* fragment to allow an interaction in this fragment to be communicated
* to the activity and potentially other fragments contained in that
* activity.
* <p>
* See the Android Training lesson <a href=
* "http://developer.android.com/training/basics/fragments/communicating.html"
* >Communicating with Other Fragments</a> for more information.
*/
public interface OnFragmentInteractionListener {
// TODO: Update argument type and name
void onFragmentInteraction(Uri uri);
}
}
this is my fragment_profile.xml
<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="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:fitsSystemWindows="true"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" >
<TextView
android:textColor="#android:color/white"
android:text="Profile"
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20dp"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout 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:background="#d2cfcf">
<!-- TODO: Update blank fragment layout -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:src="#drawable/man" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Joko Tingkir"
android:textColor="#android:color/black"
android:textSize="25dp" />
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="UangKu: "
android:textColor="#color/colorPrimary"
android:textSize="25dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 70.000,-"
android:textColor="#android:color/black"
android:textSize="25dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="No Rekening: "
android:textColor="#android:color/black"
android:textSize="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="34-5563-4564-34"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="A/N: NarutoU"
android:textColor="#android:color/black" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Profil Diri"
android:textColor="#color/colorPrimary"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#android:color/darker_gray"></View>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/mailijo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="uzumaki.naruto#konoha.com"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/sex_type" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Pria"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/handphone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="081290188409"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/rumah" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Konoha, Kab. Konohagakure, Negara Api, Indonesia"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/kalender" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="10 Oktober 1997"
android:textColor="#android:color/black" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"></View>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
and suddenly I got this error messege
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.mqa.android.ewasapp, PID: 16111
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:430)
at android.view.LayoutInflater.createView(LayoutInflater.java:652)
at com.android.internal.policy.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:58)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:742)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:810)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:752)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:883)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:886)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:846)
at android.view.LayoutInflater.inflate(LayoutInflater.java:522)
at android.view.LayoutInflater.inflate(LayoutInflater.java:430)
at com.mqa.android.ewasapp.ProfilFragment.onCreateView(ProfilFragment.java:67)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:700)
at android.os.Handler.handleCallback(Handler.java:754)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:163)
at android.app.ActivityThread.main(ActivityThread.java:6337)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:880)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:770)
Caused by: java.lang.OutOfMemoryError: Failed to allocate a 34776012 byte allocation with 16777216 free bytes and 32MB until OOM
at dalvik.system.VMRuntime.newNonMovableArray(Native Method)
at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:624)
at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:457)
at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:1152)
at android.content.res.ResourcesImpl.createFromResourceStream(ResourcesImpl.java:1272)
at android.content.res.ResourcesImpl.loadDrawableForCookie(ResourcesImpl.java:743)
E/AndroidRuntime: at android.content.res.ResourcesImpl.loadDrawable(ResourcesImpl.java:585)
at android.content.res.MiuiResourcesImpl.loadDrawable(MiuiResourcesImpl.java:308)
at android.content.res.Resources.loadDrawable(Resources.java:872)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.widget.ImageView.<init>(ImageView.java:157)
at android.widget.ImageView.<init>(ImageView.java:145)
at android.widget.ImageView.<init>(ImageView.java:141)
this is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.mqa.android.ewasapp"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.android.gms:play-services-plus:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.google.android.gms:play-services-maps:11.8.0'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.google.android.gms:play-services-location:11.8.0'
}
the messenge said that the error in this line
return inflater.inflate(R.layout.fragment_profile, container, false);
please help me to fix it
Add two lines in your style.xml :
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
copy and paste whole xml it will work :-
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="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:fitsSystemWindows="true"
android:orientation="vertical"
tools:context=".MainActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/colorPrimary"
app:popupTheme="#style/AppTheme.PopupOverlay" >
<TextView
android:textColor="#android:color/white"
android:text="Profile"
android:layout_marginLeft="11dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="bold"
android:textSize="20dp"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<FrameLayout 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:background="#d2cfcf">
<!-- TODO: Update blank fragment layout -->
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="130dp"
android:layout_gravity="center_horizontal"
android:layout_margin="10dp"
android:src="#drawable/man" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Joko Tingkir"
android:textColor="#android:color/black"
android:textSize="25dp" />
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="UangKu: "
android:textColor="#color/colorPrimary"
android:textSize="25dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rp. 70.000,-"
android:textColor="#android:color/black"
android:textSize="25dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="No Rekening: "
android:textColor="#android:color/black"
android:textSize="16dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="34-5563-4564-34"
android:textColor="#android:color/black"
android:textSize="15dp" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="A/N: NarutoU"
android:textColor="#android:color/black" />
</LinearLayout>
</android.support.v7.widget.CardView>
</LinearLayout>
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="10dp"
card_view:cardCornerRadius="2dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/rectangle"
android:orientation="vertical"
android:padding="10dp">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Profil Diri"
android:textColor="#color/colorPrimary"
android:textSize="20dp" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="5dp"
android:background="#android:color/darker_gray"></View>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/mailijo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="uzumaki.naruto#konoha.com"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/sex_type" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Pria"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/handphone" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="081290188409"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/rumah" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="Konoha, Kab. Konohagakure, Negara Api, Indonesia"
android:textColor="#android:color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="5dp"
android:orientation="horizontal">
<ImageView
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/kalender" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text="10 Oktober 1997"
android:textColor="#android:color/black" />
</LinearLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
<View
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="5dp"></View>
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
</FrameLayout>
</LinearLayout>
see this :-
When I copied your code into my studio this error will show you can see in below:-
My EditText is at the bottom of screen, so when I'm tapping on it to edit it, the keyboard is hiding it. I want that when I tap on EditText, the keyboard should remain below it & should not hide it.
Here's the link to the screenshot showing EditText before tapping on it: http://imgur.com/cgme1HT
Here's the link to the screenshot after tapping on EditText (the EditText field is below the keyboard now): http://imgur.com/nloFrkn
Here's my SettingUpUserProfile.java file's code:
public class SettingUpUserProfile extends AppCompatActivity {
public static final int TAKE_PHOTO_REQUEST = 0;
public static final int PICK_PHOTO_REQUEST = 1;
private static final int RESULT_LOAD_IMG = 2;
String imgDecodableString;
protected ImageView userProfilePicture;
#Override
protected void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting_up_user_profile);
userProfilePicture = (ImageView) findViewById(R.id.userProfilePicture);
userProfilePicture.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
AlertDialog.Builder builder = new AlertDialog.Builder(SettingUpUserProfile.this);
builder.setTitle(null);
builder.setItems(R.array.pickImage_options, new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int position) {
switch (position) {
case 0:
Intent intentCaptureFromCamera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intentCaptureFromCamera, TAKE_PHOTO_REQUEST);
break;
case 1:
Intent chooseFromGalley = new Intent(Intent.ACTION_GET_CONTENT);
chooseFromGalley.setType("image/*");
startActivityForResult(chooseFromGalley, PICK_PHOTO_REQUEST);
break;
}
}
});
AlertDialog alertDialog = builder.create();
alertDialog.show();
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
// When an Image is picked
Uri uri = data.getData();
try {
Bitmap bitmap = MediaStore.Images.Media.getBitmap(getContentResolver(), uri);
// Log.d(TAG, String.valueOf(bitmap));
ImageView imageView = (ImageView) findViewById(R.id.userProfilePicture);
imageView.setImageBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
} catch (Exception e) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)
.show();
}
}
}
Here's my activity_setting_up_user_profile.xml file's code:
<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:background="#color/light_purple"
tools:context="com.abc.xyz.SettingUpUserProfile">
<TextView
android:id="#+id/settingUpUserProfileText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="#string/settingUpUserProfileText1"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="30sp"
android:gravity="center_horizontal|center_vertical"/>
<ImageView
android:id="#+id/userProfilePicture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/settingUpUserProfileText1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="100dp"
android:clickable="true"
android:src="#drawable/ic_face_white_48dp" />
<TextView
android:id="#+id/settingUpUserProfileText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userProfilePicture"
android:layout_marginTop="5dp"
android:text="#string/settingUpUserProfileText2"
android:textColor="#color/white"
android:textSize="15sp"
android:gravity="center_horizontal|center_vertical"/>
<EditText
android:id="#+id/userName"
android:background="#drawable/phone_number_edit_text_design"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settingUpUserProfileText2"
android:layout_marginTop="80dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:gravity="center_horizontal|center_vertical"
android:hint="#string/hint_userName"
android:textColor="#color/white"
android:textColorHint="#E0E0E0"
android:textCursorDrawable="#null"
android:inputType="textPersonName"/>
<Button
android:id="#+id/buttonAllSet"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_marginTop="20dp"
android:text="#string/button_allSet"
android:textStyle="bold"
android:textColor="#color/light_purple"
android:layout_marginEnd="120dp"
android:layout_marginStart="120dp"
android:gravity="center_horizontal|center_vertical"/>
</RelativeLayout>
I really have no clue about what to do here!
Please let me know.
I'm new to StackOverflow, so please cooperate.
Thanks in advance.
I had the same issue where the softkeyboard was on top of the EditText views which were placed on the bottom of the screen. I was able to find a solution by adding a single line to my AndroidManifest.xml file's relevant activity.
Put layout inside a ScrollView.
android:windowSoftInputMode="adjustResize|stateHidden"
This is how the whole activity tag looks like:
<activity
android:name="com.my.MainActivity"
android:screenOrientation="portrait"
android:label="#string/title_activity_main"
android:windowSoftInputMode="adjustResize|stateHidden" >
</activity>
Here the most important value is the adjustResize. This will shift the whole UI up to give room for the softkeyboard.
Simply use a ScrollView as the parent view in your xml file.
Options-1
Try using android:windowSoftInputMode="adjustPan" in activity in AndroidManifest.xml
Options-2
Use ScrollView as parent in xml. Replace your xml with this:
<ScrollView 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"
tools:context="com.abc.xyz.SettingUpUserProfile" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/light_purple">
<TextView
android:id="#+id/settingUpUserProfileText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:text="#string/settingUpUserProfileText1"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="30sp"
android:gravity="center_horizontal|center_vertical"/>
<ImageView
android:id="#+id/userProfilePicture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/settingUpUserProfileText1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="100dp"
android:clickable="true"
android:src="#drawable/ic_face_white_48dp" />
<TextView
android:id="#+id/settingUpUserProfileText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userProfilePicture"
android:layout_marginTop="5dp"
android:text="#string/settingUpUserProfileText2"
android:textColor="#color/white"
android:textSize="15sp"
android:gravity="center_horizontal|center_vertical"/>
<EditText
android:id="#+id/userName"
android:background="#drawable/phone_number_edit_text_design"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settingUpUserProfileText2"
android:layout_marginTop="80dp"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:layout_marginRight="10dp"
android:layout_marginEnd="10dp"
android:gravity="center_horizontal|center_vertical"
android:hint="#string/hint_userName"
android:textColor="#color/white"
android:textColorHint="#E0E0E0"
android:textCursorDrawable="#null"
android:inputType="textPersonName"/>
<Button
android:id="#+id/buttonAllSet"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_marginTop="20dp"
android:text="#string/button_allSet"
android:textStyle="bold"
android:textColor="#color/light_purple"
android:layout_marginEnd="120dp"
android:layout_marginStart="120dp"
android:gravity="center_horizontal|center_vertical"/>
</RelativeLayout>
</ScrollView>
Thank you all for your answers.
I solved the problem by changing my activity_setting_up_user_profile.xml file's code to this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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:orientation="vertical"
android:background="#color/light_purple"
tools:context="com.abc.xyz.SettingUpUserProfile" >
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/settingUpUserProfileText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center_horizontal|center_vertical"
android:text="#string/settingUpUserProfileText1"
android:textColor="#color/white"
android:textSize="30sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/userProfilePicture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/settingUpUserProfileText1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="100dp"
android:clickable="true"
android:src="#drawable/ic_face_white_48dp" />
<TextView
android:id="#+id/settingUpUserProfileText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userProfilePicture"
android:layout_marginTop="5dp"
android:gravity="center_horizontal|center_vertical"
android:text="#string/settingUpUserProfileText2"
android:textColor="#color/white"
android:textSize="15sp" />
<EditText
android:id="#+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settingUpUserProfileText2"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="80dp"
android:background="#drawable/phone_number_edit_text_design"
android:gravity="center_horizontal|center_vertical"
android:hint="#string/hint_userName"
android:inputType="textPersonName"
android:textColor="#color/white"
android:textColorHint="#E0E0E0"
android:textCursorDrawable="#null" />
<Button
android:id="#+id/buttonAllSet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_marginEnd="120dp"
android:layout_marginStart="120dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:gravity="center_horizontal|center_vertical"
android:text="#string/button_allSet"
android:textColor="#color/light_purple"
android:textStyle="bold" />
</RelativeLayout>
</ScrollView>
</LinearLayout>
This was COOL!
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.abc.xyz.SettingUpUserProfile" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/light_purple" >
<TextView
android:id="#+id/settingUpUserProfileText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dp"
android:gravity="center_horizontal|center_vertical"
android:text="#string/settingUpUserProfileText1"
android:textColor="#color/white"
android:textSize="30sp"
android:textStyle="bold" />
<ImageView
android:id="#+id/userProfilePicture"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_below="#+id/settingUpUserProfileText1"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="100dp"
android:clickable="true"
android:src="#drawable/ic_face_white_48dp" />
<TextView
android:id="#+id/settingUpUserProfileText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userProfilePicture"
android:layout_marginTop="5dp"
android:gravity="center_horizontal|center_vertical"
android:text="#string/settingUpUserProfileText2"
android:textColor="#color/white"
android:textSize="15sp" />
<EditText
android:id="#+id/userName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/settingUpUserProfileText2"
android:layout_marginEnd="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginStart="10dp"
android:layout_marginTop="80dp"
android:background="#drawable/phone_number_edit_text_design"
android:gravity="center_horizontal|center_vertical"
android:hint="#string/hint_userName"
android:inputType="textPersonName"
android:textColor="#color/white"
android:textColorHint="#E0E0E0"
android:textCursorDrawable="#null" />
<Button
android:id="#+id/buttonAllSet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/userName"
android:layout_marginEnd="120dp"
android:layout_marginStart="120dp"
android:layout_marginTop="20dp"
android:background="#color/white"
android:gravity="center_horizontal|center_vertical"
android:text="#string/button_allSet"
android:textColor="#color/light_purple"
android:textStyle="bold" />
</RelativeLayout>
</LinearLayout>
</ScrollView>