I am creating a form in which I have specified some EditText and some TextView . At last I have specified a Checkbox like this:
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
But this checkbox is not getting displayed in the layout when the app is running. What is going wrong here.
My full layout.xml is :
<?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"
tools:context="com.schoolcounter.ui.activity.teacher.AddHomeworkActivity">
<LinearLayout
android:id="#+id/addHomeworkForm"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp">
<LinearLayout
android:id="#+id/selectClassLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/select_class"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_class"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textStyle="bold"
android:textSize="#dimen/text_size" />
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_class_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_class"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size" />
</LinearLayout>
<LinearLayout
android:id="#+id/selectSectionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/select_section"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_section"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_section_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_section"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:id="#+id/selectSubjectLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/select_subject"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/select_subject"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/select_subject_spinner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="start"
android:hint="#string/select_subject"
android:textAlignment="viewStart"
android:textColorHint="#color/colorHint"
android:textSize="#dimen/text_size"/>
</LinearLayout>
<LinearLayout
android:id="#+id/uploadedDateLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_uploaded_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/text_uploaded_date"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextUploadedDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="#dimen/text_size"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:id="#+id/completionDateLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_completion_date"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:paddingRight="#dimen/text_padding"
android:paddingTop="#dimen/text_padding"
android:paddingBottom="#dimen/text_padding"
android:text="#string/text_completion_date"
android:textAlignment="textEnd"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextCompletionDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textSize="#dimen/text_size"
android:focusable="false"
android:focusableInTouchMode="false"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="#+id/textView_Homework"
android:text="#string/text_homework"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/text_padding"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextHomeworkText"
android:layout_width="match_parent"
android:layout_height="74dp"
android:ems="10"
android:inputType="textMultiLine"
android:textSize="#dimen/text_size"/>
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:weightSum="1">
<Button
android:id="#+id/uploadHomeworkButton"
style="#style/button_style_corners"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginBottom="16dp"
android:layout_marginTop="16dp"
android:text="#string/text_upload"
android:textAlignment="center"
android:textColor="#color/colorWhite" />
</LinearLayout>
</LinearLayout>
</ScrollView>
You have to change the width attribute value of EditText 'editTextHomeworkText' in
<TextView
android:id="#+id/textView_Homework"
android:text="#string/text_homework"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="#dimen/text_padding"
android:textColor="#color/colorPrimary"
android:textSize="#dimen/text_size"
android:textStyle="bold"/>
<EditText
android:id="#+id/editTextHomeworkText"
android:layout_width="match_parent"
android:layout_height="74dp"
android:ems="10"
android:inputType="textMultiLine"
android:textSize="#dimen/text_size"/>
<CheckBox
android:id="#+id/sendAsSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Send As SMS"
android:checked="false"
android:textSize="16sp"
/>
</LinearLayout>
Since you assigned the width value as 'match_parent' all the remaining space is covered by EditText only. Here either you can change the value to 'wrap_content' or do it like
android:layout_width="0dp"
android:layout_weight="1"
Related
i have this layout :enter image description here
as you see at the end of the textview I have missing word displaying outside of the textview it should be displayed in the next line I didn't found a way to solve this problme.n the case of (utilisateurs) it is displaying fine by the way .
Here is my xml code :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="12dp"
android:orientation="vertical">
<TextView
android:id="#+id/clickName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickid"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickStatus"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickDate"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickType"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickPriority"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickImpact"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickUrgency"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<TextView
android:id="#+id/clickcontent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:layout_weight="1"
android:background="#drawable/round_edittext"
android:text="TextView"
android:textColor="#color/white"
android:textStyle="italic" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="horizontal">
<Button
android:id="#+id/traitement"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Traitement " />
</LinearLayout>
</LinearLayout>
<com.getbase.floatingactionbutton.FloatingActionsMenu
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="24dp"
app:fab_addButtonColorNormal="#color/yellow"
app:fab_labelStyle="#style/floting_button">
<com.getbase.floatingactionbutton.FloatingActionButton
android:id="#+id/fab_supprimer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:fab_colorNormal="#color/dark_blue"
app:fab_icon="#drawable/ic_supprimer"
app:fab_title="Supprimer ticket" />
</com.getbase.floatingactionbutton.FloatingActionsMenu>
appreciate any help
use padding within the TextView to solve the problem.
I need to align the images and buttons equall with the header but it's not assigning. When I check in landscape, align getting mismatch. Here is my code.
When I checked in device, it's not fitting correctly.
Below is the code and output screen (My output and actual output which needed).
I used weight but it's not fitting correctly in all devices.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:layout_gravity="center_horizontal"
android:gravity="center"
android:layout_marginLeft="8dp"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight=".2">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
My Output:
Actual output:
Here i have fixed the issue for you. But as the screen size will increase so does the size between your button and upper portion too. But your layout won't get messy. And if you want everything to remain fixed even on bigger screen sizes then you should use constraintLayout.
<?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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorPrimaryLight">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/textView9"
android:layout_alignBottom="#+id/textView9"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="50dp"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:layout_centerVertical="true"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginRight="10dp"
android:text="Pindahkan ke hari" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal"
android:baselineAligned="false">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:weightSum="4">
<com.hutchison.h3i.newangie.customviews.CircleImageView
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="0.5"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="sad234 234234"
android:textColor="#color/primary_text"
android:textSize="12sp" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/title_activity_test"
android:textColor="#color/secondary_text"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="8dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:gravity="center"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/primary_text" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight=".5">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:background="#drawable/ic_add"
android:gravity="center"
android:textColor="#color/primary_text"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="10dp"
android:layout_weight="1.5">
<android.support.v7.widget.AppCompatButton
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="#drawable/bg_spinner_nothing_selected"
android:drawableRight="#drawable/ic_edit_grey"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/primary_text"
android:textSize="14sp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
Hope it will help you. I have replaced the colors and ic_images with mine you will have to change them too by your own.
Hope this would work. I redesign with your same xml 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"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="29dp"
android:layout_marginTop="16dp"
android:background="#color/colorAlabaster">
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Retailer" />
<TextView
android:id="#+id/textView9"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Hari sebelumnya" />
<TextView
android:layout_width="0dp"
android:layout_weight=".2"
android:layout_height="wrap_content"
android:gravity="center" />
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Pindahkan ke hari" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:orientation="horizontal">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginLeft="8dp"
android:layout_weight="1">
<LinearLayout
android:layout_weight="1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="horizontal">
<com.hutchison.h3i.newangie.customviews.CircleImageViewx
android:id="#+id/recycle_profile"
android:layout_width="#dimen/growth_sell_in_out_icon_size"
android:layout_height="#dimen/growth_sell_in_out_icon_size"
android:layout_gravity="center"
android:layout_marginLeft="16dp"
android:src="#drawable/ic_default_profile" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/recycle_txt_acc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_number"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_very_small" />
<TextView
android:id="#+id/recycle_txt_acc_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="false"
android:text="#string/route_plan_default_name"
android:textColor="#color/colorCyan"
android:textSize="#dimen/text_size_very_small" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:background="#drawable/border_grey_curve"
android:text="Selasa"
android:textAllCaps="false"
android:textColor="#color/colorBlack" />
</LinearLayout>
<LinearLayout
android:layout_weight=".2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="center">
<ImageView
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center"
android:background="#drawable/ic_arrow_right"
android:gravity="center"
android:textColor="#color/colorBlack"
android:textSize="16dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1">
<android.support.v7.widget.AppCompatButton
android:layout_width="86dp"
android:layout_height="29dp"
android:background="#drawable/border_grey_curve"
android:drawablePadding="5dp"
android:drawableRight="#drawable/ic_arrow_bottom"
android:singleLine="true"
android:text="Kamis"
android:textAllCaps="false"
android:textColor="#color/colorBlack"
android:textSize="#dimen/text_size_small" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I saw so many people ask the same question in here, but I still cannot find the reason why my scrollview doesn't work.
Here is my Layout
<?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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/itemImage"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
That is so weird, because I finished other layout use the scrollview it's work fine, but in this activity the scrollview doesn't even show in preview.
There no scroll
You have your LinearLayout height set to fill_parent which is deprecated but is the same thing is match_parent instead your LinearLayout height should be set to wrap_content.
The reason is that your LinearLayout has the same exact height as the ScrollView so there is no need to scroll. If you set it to wrap_content the LinearLayout can have a height larger then the ScrollView which will scroll to show what is outside of ScrollViews bounds
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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_margin="5dp"
android:paddingBottom="16dp"
android:scaleType="fitXY"
android:id="#+id/itemImage"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
Just realize how stupid am I , i finish fixed this problem.
<?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:id="#+id/activity_upload"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp"
android:fillViewport="true"
tools:context="com.example.daniw.traekle.upload">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:text="Choose Image"
android:id="#+id/b_chooseImage"/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
android:layout_marginBottom="5dp"
android:paddingBottom="50dp"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:paddingTop="3dp"
android:scaleType="fitXY"
android:id="#+id/itemImage"/>
<TextView
android:id="#+id/tv_itemName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Name"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="20sp"
android:layout_marginBottom="5dp"/>
<EditText
android:id="#+id/et_itemTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Title"
android:layout_marginBottom="5dp"
android:textColor="#000000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:text="Book ISBN(option)"
android:id="#+id/tv_bISBN"
android:textSize="20sp"
android:textStyle="bold"
android:textColor="#000000" />
<EditText
android:id="#+id/et_ISBN"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:textColor="#000000"
android:text="test"/>
<TextView
android:id="#+id/tv_itemPrice"
android:text="Price"
android:textStyle="bold"
android:textSize="20sp"
android:textColor="#000000"
android:layout_marginBottom="5dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:id="#+id/et_itemPrice"
android:text="Test"
android:textColor="#000000"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"/>
<TextView
android:id="#+id/tv_itemDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Item Description"
android:textSize="20sp"
android:textColor="#000000"
android:textStyle="bold"
android:layout_marginBottom="5dp"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/inputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="true"
app:counterMaxLength="600"
app:counterOverflowTextAppearance="#style/MyOverflowText">
<EditText
android:id="#+id/et_itemDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:text="Test"
android:maxLength="600"
android:textColor="#000000"/>
</android.support.design.widget.TextInputLayout>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Post Item"
android:id="#+id/bPost"/>
</LinearLayout>
</ScrollView>
Now this layout working fine
I want to make each EditText separated from the others.
But when I select the first EditText it shows the next EditText instead of submit or confirm then goes to the next EditText and so on.
Here is the xml code.
<?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"
tools:context="com.example.ommabdelhafiz.amathmess.MainActivity">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="7"
android:textSize="32sp"
android:id="#+id/first_1st"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="×"
android:textSize="32sp"
/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="7"
android:textSize="32sp"
android:id="#+id/first_2nd"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="="
android:textSize="32sp"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:hint="Ans"
android:inputType="number"
android:maxLength="3"
android:id="#+id/first_ans"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:layout_gravity="center_horizontal"
android:id="#+id/first_true_ans"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:gravity="bottom"
android:layout_gravity="center_horizontal"
android:id="#+id/first_false_ans"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="49"
android:textSize="32sp"
android:id="#+id/second_1st"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="÷"
android:textSize="32sp"
/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="7"
android:textSize="32sp"
android:id="#+id/second_2nd"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="="
android:textSize="32sp"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:hint="Ans"
android:inputType="number"
android:maxLength="2"
android:id="#+id/second_ans"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:layout_gravity="center_horizontal"
android:id="#+id/second_true_ans"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:gravity="bottom"
android:layout_gravity="center_horizontal"
android:id="#+id/second_false_ans"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="140dp"
android:layout_height="wrap_content"
android:text="711"
android:textSize="32sp"
android:id="#+id/third_1st"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="×"
android:textSize="32sp"
/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="7"
android:textSize="32sp"
android:id="#+id/third_2nd"/>
<TextView
android:layout_width="80dp"
android:layout_height="wrap_content"
android:text="="
android:textSize="32sp"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="32sp"
android:hint="Ans"
android:inputType="number"
android:maxLength="4"
android:id="#+id/third_ans"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:layout_gravity="center_horizontal"
android:id="#+id/third_true_ans"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textSize="16dp"
android:gravity="bottom"
android:layout_gravity="center_horizontal"
android:id="#+id/third_false_ans"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
</RelativeLayout>
Set android:imeOptions="actionSend" or android:imeOptions="actionDone" on your first edit text. By default, when you don't specify anything and there is a next edit text, Android will set android:imeOptions="actionNext" so you need to override this default.
I am new to Android and working on a App and stuck here on ScrollView. I have tried width and height "match parent" but still not working. I am posting my code. I have wasted more than an hour on this. Thanks in advance.
Here is my XML:
<?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:weightSum="1"
android:orientation="vertical">
<LinearLayout
android:id="#+id/linear_header"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.02"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="20dp"
android:text="Marketing"
android:textColor="#color/black"
android:textSize="25dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:id="#+id/linear_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linear_header"
android:layout_weight="0.02"
android:background="#color/light_blue"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="15dp"
android:text="Register Here"
android:textColor="#color/white"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<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:layout_below="#+id/linear_register"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="20dp"
android:layout_weight="0.04"
android:orientation="vertical">
<EditText
android:id="#+id/edit_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Name*"
android:inputType="text" />
<EditText
android:id="#+id/edit_email"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Email*"
android:inputType="text" />
<EditText
android:id="#+id/edit_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Password*"
android:inputType="text" />
<EditText
android:id="#+id/edit_cnfrm_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:hint="Confirm Password*"
android:inputType="text" />
<Button
android:id="#+id/btn_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginLeft="50dp"
android:layout_marginRight="50dp"
android:layout_marginTop="20dp"
android:background="#drawable/button_bg"
android:padding="15dp"
android:text="Register"
android:textStyle="bold" />
<TextView
android:id="#+id/txt_forgot_pswd"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:text="Forgot/Reset Password"
android:textColor="#color/light_blue" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:weightSum="1"
android:layout_marginBottom="10dp"
android:orientation="horizontal">
<Button
android:id="#+id/btn_google"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="GOOGLE"
android:textColor="#color/white"
android:textStyle="bold"
android:textSize="15sp"
android:layout_marginRight="5dp"
android:background="#color/red"
android:layout_weight="0.5"/>
<Button
android:id="#+id/btn_facebook"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="FACEBOOK"
android:textColor="#color/white"
android:background="#color/fb_blue"
android:layout_marginLeft="5dp"
android:textStyle="bold"
android:textSize="15sp"
android:layout_weight="0.5"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
set lay out weight to scroll view like
<ScrollView
android:layout_weight="0.96"
android:layout_width="match_parent"
android:layout_height="wrap_content">