I'am having a layout with ScrollView. I'am unable to view all the items as soon as my layout is opened
I'am unable to scroll down complete but after editing something in EditText and if I again scroll I'am able to view all the items.
Please help in solving this issue.
Below is my layout file
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingLeft="20dp"
android:paddingRight="20dp"
android:layout_alignParentTop="true"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Diabetes Risk Assesment"
android:textStyle="bold"
android:gravity="center"
android:textSize="20dp"
android:textColor="#00abea"/>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_diabetesage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="30dp">
<EditText
android:id="#+id/input_diabetes"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
android:hint="#string/hint_age"
/>
</android.support.design.widget.TextInputLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="Gender"
android:paddingTop="20dp"
android:textSize="15dp"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:id="#+id/diaradiogroup">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Male"
android:id="#+id/rmale"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Female"
android:id="#+id/rfemale"/>
</RadioGroup>
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_diabeteswaist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="30dp">
<EditText
android:id="#+id/input_waist"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:inputType="number"
android:hint="#string/hint_waist"
/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/strexercise"
android:paddingTop="20dp"
android:textSize="15dp"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:id="#+id/diaexxercise">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes"
android:id="#+id/remale"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:id="#+id/refemale"/>
</RadioGroup>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/strexercisedaily"
android:paddingTop="20dp"
android:textSize="15dp"
android:textStyle="bold"/>
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:id="#+id/exercisedaily">
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Yes"
android:id="#+id/redmale"/>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="No"
android:id="#+id/redfemale"/>
</RadioGroup>
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/strparents"
android:paddingTop="20dp"
android:textSize="15dp"
android:textStyle="bold"/>
<Spinner
android:id="#+id/spingender"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#style/spinner_style"
/>
</LinearLayout>
<!--<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>-->
</LinearLayout>
</ScrollView>
Maybe that's because your EditText is being focused by default.
You can remove that by adding this line in your onCreate() in your activity.
this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
Hope this helps :)
After hours of search i founnd a solution for my problem.
add this attribute in scrollview -- app:layout_behavior="#string/appbar_scrolling_view_behavior"
and remove the same attribute from the ViewPager
So the layout ScrollView should be below
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
android:fillViewport="true">
and ViewPager should be like this
<android.support.v4.view.ViewPager
android:id="#+id/viewpager2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
Related
I have this form and when the soft keyboard is open, the screen does not resize and dont make scroll on it.
I really want to know why. Why my view does not scroll? Why does not resize?
This is my xml:
<?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"
android:fitsSystemWindows="true"
>
<ScrollView
android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/transparent"
android:visibility="invisible"
app:navigationIcon="#drawable/ic_left_arrow"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/imageView9"
android:layout_width="180dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:src="#drawable/logo" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView9"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/imageView9"
android:layout_below="#+id/imageView9"
android:layout_marginLeft="15dp"
android:paddingBottom="6dp"
android:text="OFERTAR OU \nSIMULAR LANCE"
android:textColor="#eb262a"
android:textSize="20sp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/livre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Livre" />
<RadioButton
android:id="#+id/fixo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Fixo" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Percentual do lance">
<EditText
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/textView12"
android:layout_toStartOf="#+id/textView12"
android:ems="10"
android:inputType="numberDecimal"
android:nextFocusDown="#+id/value"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/textView12"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="%"
android:textColor="#000"
android:textSize="16dp"
android:textStyle="bold" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Valor do lance">
<EditText
android:id="#+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="Número do Protocolo">
<EditText
android:id="#+id/protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:textSize="14dp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="#+id/limpar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Limpar"
android:textColor="#ffffff"
android:visibility="visible" />
<Button
android:id="#+id/simular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Simular"
android:textColor="#ffffff"
android:visibility="visible" />
<Button
android:id="#+id/registrar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Registrar"
android:textColor="#ffffff"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="#+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:text="Lance Fixo é definido em 30%"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:visibility="gone" />
</LinearLayout>
</ScrollView>
</LinearLayout>
I already tried set match_parent to scrollview.
And I have this in my manifest android:windowSoftInputMode="stateAlwaysHidden|adjustResize".
If you are using "FULLSCREEN" theme for your application or activity then the "RESIZE" functionality will not work, you should use "NoTitleBar" theme without "FULLSCREEN".
It will work 100%.
And you should use "RelativeLayout" in place of parent layout(main linearlayout).
I found the problem. I'm using <item name="android:windowFullscreen">true</item>
and when the fullscreen flags are actived, the resize dont work.
If you want to resize the activity when the keyboard pops up you need to specify a line of code in manifest file inside activity tag :
android:windowSoftInputMode="adjustResize"
Refer this link for more details : https://developer.android.com/training/keyboard-input/visibility.html
You can even try to adjust screen in activity put the below code in you activity onCreate method:
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE|WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
Hope this should help!!
add this line to activity which you want to resize on opening soft keyboard:
android:windowSoftInputMode="adjustResize"
UPDATE POST:
<?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"
android:fitsSystemWindows="true"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:id="#+id/relativeLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="10dp"
android:background="#android:color/transparent"
android:visibility="invisible"
app:navigationIcon="#drawable/ic_left_arrow"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light">
</android.support.v7.widget.Toolbar>
<ImageView
android:id="#+id/imageView9"
android:layout_width="180dp"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/toolbar"
android:layout_gravity="center_vertical|center_horizontal"
android:layout_marginLeft="10dp"
android:src="#drawable/logo"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/imageView9"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignStart="#+id/imageView9"
android:layout_below="#+id/imageView9"
android:layout_marginLeft="15dp"
android:paddingBottom="6dp"
android:text="OFERTAR OU \nSIMULAR LANCE"
android:textColor="#eb262a"
android:textSize="20sp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="horizontal">
<RadioButton
android:id="#+id/livre"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Livre"/>
<RadioButton
android:id="#+id/fixo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Lance Fixo"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Percentual do lance">
<EditText
android:id="#+id/percent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/textView12"
android:layout_toStartOf="#+id/textView12"
android:ems="10"
android:inputType="numberDecimal"
android:nextFocusDown="#+id/value"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
<TextView
android:id="#+id/textView12"
android:layout_width="25dp"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:text="%"
android:textColor="#000"
android:textSize="16dp"
android:textStyle="bold"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1">
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Valor do lance">
<EditText
android:id="#+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="numberDecimal"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
</LinearLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/text_input_layout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:hint="Número do Protocolo">
<EditText
android:id="#+id/protocol"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="number"
android:textSize="14dp"/>
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="30dp"
android:orientation="horizontal"
android:weightSum="10">
<Button
android:id="#+id/limpar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Limpar"
android:textColor="#ffffff"
android:visibility="visible"/>
<Button
android:id="#+id/simular"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Simular"
android:textColor="#ffffff"
android:visibility="visible"/>
<Button
android:id="#+id/registrar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:backgroundTint="#android:color/holo_red_light"
android:text="Registrar"
android:textColor="#ffffff"
android:visibility="gone"/>
</LinearLayout>
<TextView
android:id="#+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:layout_marginTop="20dp"
android:text="Lance Fixo é definido em 30%"
android:textAlignment="center"
android:textColor="#000"
android:textSize="16sp"
android:visibility="gone"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
I don't know why, but my layout color just stops in the bottom of the screen.
I don't think my code is doing that.
And, by the way, does anyone know where to get ideas from a simple layout like this? TextViews and EditTexts?
Mine looks awful
<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"
android:background="#color/AMOB_gray"
tools:context="com.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
<TextView
android:id="#+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="#string/material"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<Spinner
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/snipperMaterial">
</Spinner>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/diameter"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp" />
<EditText
android:id="#+id/et_diameter"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/thickness"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_thickness"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/clr"
android:textColor="#color/AMOB_yellow"
android:textSize="25dp"
android:gravity="center"/>
<EditText
android:id="#+id/et_clr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round"
android:ems="10"
android:inputType="number"
android:padding="10dp"
android:text="0"/>
<Button
android:id="#+id/btn_save_tube"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/round_buttons"
android:text="#string/save"
android:textColor="#color/AMOB_gray"
android:layout_marginTop="10dp"/>
</LinearLayout>
</ScrollView>
Instead of 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.example.tiagosilva.amob_android.TubeDataFragment" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center"
android:background="#color/AMOB_gray">
Try 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.example.tiagosilva.amob_android.TubeDataFragment"
android:background="#color/AMOB_gray">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="20dp"
android:gravity="center">
So to move the background color inside the root ViewGroup
Add below line in your scroll view. This will do what you want
android:fillViewport="true"
I have a problem with the Login Page. Don't know to arrange views as I am posting the code that I tried both in Mobile and Tab.
Thanks in advance.
Any help will be appreciated.
Below I am posting the code of Layout.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/activity_sign_in_back">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/rlBottomLayout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="#+id/ivLogo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:src="#drawable/activity_sign_in_logo" />
<EditText
android:id="#+id/etUsername"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/ivLogo"
android:layout_margin="20dp"
android:background="#drawable/edittext_unfocus_background"
android:padding="15dp" />
<EditText
android:id="#+id/etPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/etUsername"
android:layout_margin="20dp"
android:background="#drawable/edittext_unfocus_background"
android:padding="15dp" />
<LinearLayout
android:id="#+id/llRemember"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/tvNoAccount"
android:layout_below="#+id/etPassword"
android:visibility="invisible"
>
<ImageView
android:id="#+id/ivCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="right"
android:src="#drawable/activity_check_box_remember_me" />
<TextView
android:id="#+id/tvRememberView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_weight="1"
android:gravity=""
android:text="#string/text_message_remember_me"
android:textColor="#color/white"
android:textSize="#dimen/text_small_size" />
</LinearLayout>
<TextView
android:id="#+id/tvSignIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/llRemember"
android:layout_centerHorizontal="true"
android:layout_marginTop="15dp"
android:background="#drawable/view_white_border"
android:paddingBottom="10dp"
android:paddingLeft="40dp"
android:paddingRight="40dp"
android:paddingTop="10dp"
android:text="#string/text_message_sign_in"
android:textColor="#color/white"
android:textSize="#dimen/text_large_size"
android:onClick="signIn"/>
<TextView
android:id="#+id/tvForgotPassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvSignIn"
android:layout_centerHorizontal="true"
android:layout_marginBottom="10dp"
android:layout_marginTop="20dp"
android:text="#string/text_message_forgot_password"
android:textColor="#color/white"
android:textSize="#dimen/text_large_size" />
</RelativeLayout>
</ScrollView>
<LinearLayout
android:id="#+id/rlBottomLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginTop="15dp"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="#+id/tvNoAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:gravity="center"
android:text="#string/text_message_no_account"
android:textColor="#color/white"
/>
<TextView
android:id="#+id/tvSignUp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/tvNoAccount"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="15dp"
[enter image description here][1]android:background="#drawable/view_white_background"
android:padding="15dp"
android:text="#string/text_message_sign_up"
android:onClick="signUpActivity"/>
</RelativeLayout>
</ScrollView>
</LinearLayout>
</RelativeLayout>
I have attached the images one is real and other that I made. I tried to make the image as real but unable to succeed. If anyone have some idea that how to make this then please help me. I am actually trying this from last 4 hours.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:fillViewport="true"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#acacac">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/lin_bottom"
android:layout_alignParentBottom="true"
android:orientation="vertical">
<TextView
android:gravity="center"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Dont have account?"/>
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Signup Now"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/lin_bottom"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="UserNAme"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint= "password"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remember Me"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sign In" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Forgot Password?"/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Updated Please check
I am creating an activity with tabs and view pager. I used the default tabbed activity template provided by android studio to create it. My problem is that I am not able add scroll to fragments layout added in view pager.
I read from this link Add ScrollView to Tab Activity
and removed this
app:layout_behavior="#string/appbar_scrolling_view_behavior".
But when I added this line to scrollview my tabs and action bar were also gone.I have already added my fragment in scrollview but it doesn't work .
Here is my main and fragment xml
Main.xml
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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/main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true"
tools:context="com.webninjaz.kirti.dnschanger.activities.MainActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/appbar_padding_top"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#5A595B"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="#style/AppTheme.PopupOverlay">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="DNS CHANGER"
android:layout_gravity="center"
android:id="#+id/toolbar_title"
android:textSize="22sp"
android:textStyle="bold"
android:textColor="#ffffff"/>
</android.support.v7.widget.Toolbar>
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#727272"/>
</android.support.design.widget.AppBarLayout>
<android.support.v4.view.ViewPager
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Fragment xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:background="#ccc"
android:focusableInTouchMode="true">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:id="#+id/TopHeader"
android:text="Current WIFI Info"
android:paddingRight="15dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="20dp"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_marginTop="10dp"
android:orientation="horizontal"
android:layout_height="wrap_content"
android:baselineAligned="false">
<LinearLayout
android:layout_width="0dp"
android:layout_weight=".50"
android:paddingRight="5dp"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAlignment="gravity"
android:id="#+id/WiFiConnectLeft"
android:text="Wifi Name :"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAlignment="gravity"
android:id="#+id/DefaultGatewayLeft"
android:text="Default Gateway :"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAlignment="gravity"
android:id="#+id/DNS1Left"
android:text="Primary DNS :"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAlignment="gravity"
android:id="#+id/DNS2Left"
android:text="Secondary DNS :"/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right"
android:textAlignment="gravity"
android:id="#+id/CurrentIPLeft"
android:text="IP Address :"/>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight=".50"
android:paddingLeft="5dp"
android:orientation="vertical"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="left"
android:id="#+id/WiFiConnectedText"
android:textAlignment="gravity"
android:text=""/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/DefaultGatewayText"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/DNS1Text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/DNS2Text"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/CurrentIPText"/>
</LinearLayout>
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="CHANGE DNS"
android:layout_gravity="center"
android:textAlignment="gravity"
android:id="#+id/MiddleHeaderText"
android:layout_marginTop="20dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textStyle="bold"
android:textColor="#000"
android:textSize="20sp"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/tv_title"
android:orientation="horizontal"
android:weightSum="3"
android:layout_marginTop="50dp"
android:id="#+id/lin_primary"
android:gravity="center_vertical"
android:paddingRight="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/primary"
android:textStyle="bold"
android:textColor="#000"
android:id="#+id/PrimaryDNSText"
android:gravity="center"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:textSize="13sp"/>
<EditText
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1.2"
android:background="#000"
android:textColor="#ffffff"
android:inputType="numberDecimal"
android:layout_marginRight="10dp"
android:maxLength="16"
android:id="#+id/EDITDNS1"
android:gravity="center"
android:text=""/>
<Button
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.8"
android:text="BROWSE"
android:gravity="center"
android:background="#drawable/textview_click"
android:textColor="#ffffff"
android:id="#+id/BrowseDNS1"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_below="#+id/lin_primary"
android:orientation="horizontal"
android:weightSum="3"
android:layout_marginTop="30dp"
android:id="#+id/lin_secondary"
android:gravity="center_vertical"
android:paddingRight="15dp">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/secondary"
android:textColor="#000"
android:id="#+id/SecondaryDNSText"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:textSize="12sp"
android:gravity="center"/>
<EditText
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="1.2"
android:background="#000"
android:textColor="#ffffff"
android:inputType="numberDecimal"
android:layout_marginRight="10dp"
android:maxLength="16"
android:id="#+id/EDITDNS2"
android:gravity="center"
android:text=""
/>
<Button
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_weight="0.8"
android:text="BROWSE"
android:gravity="center"
android:background="#drawable/textview_click"
android:textColor="#ffffff"
android:id="#+id/BrowseDNS2"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:gravity="center"
android:layout_marginTop="15dp"
android:layout_height="wrap_content">
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:id="#+id/UpdateDNS"
android:text="Update"
android:background="#drawable/textview_click"
android:textColor="#ffffff"/>
<Button
android:layout_width="wrap_content"
android:layout_height="40dp"
android:id="#+id/ResetWifi"
android:text="RESET"
android:background="#drawable/textview_click"
android:textColor="#ffffff"
android:layout_marginLeft="20dp"/>
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
I think you have to add this in line in scroll view and delete from view pager.
Scroll view may be like this.
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
I had to add this to linear layout:
android:paddingBottom="100dp"
Seems the Viewpager/container view is set to be larger than the device screen somewhere.
Can we use single linear layout or other equivalent layout to display the view as per below image view order.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="50" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="FirstName"/>
<EditText
android:id="#+id/edi1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter First Name"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_weight="50" >
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="LastName" />
<EditText
android:id="#+id/edi2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter Last Name"/>
<Button
android:id="#+id/button1"
android:text="Click Me"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>
use the above code
This will give you what you want and conform to material design guidelines:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout android:layout_width="0dp"
android:layout_weight="1"
android:hint="Firstname"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout android:layout_width="0dp"
android:layout_weight="1"
android:hint="Lastname"
android:layout_height="wrap_content">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
You'll need to add compile 'com.android.support:design:23.1.1' to your app's build.gradle file.
The below code show that how you can do this:
<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:baselineAligned="false" >
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Firstname" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Enter your firstname..." />
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hi"
android:layout_gravity="left"/>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Bye"
android:layout_gravity="right"></Button>
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="Lastname" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:hint="Enter your lastname..." />
<Button
android:id="#+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="hello"
android:layout_gravity="center_horizontal"/>
<Button
android:id="#+id/button4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="goodbye"
android:layout_gravity="right"/>
</LinearLayout>
</LinearLayout>
Important:This code only show you how to use layout_weight and layout_gravity.