How to do horizontal scrolling,vertical scrolling and tab box textview horizontal scrolling in an activity - android-layout

I am facing some problem in designing one screen in which vertical page scrolling, horizontal page scrolling and tab box textview horizontal scrolling work(if textView bigger than box).
I have attach a required image. please give me some idea, so that i can design this screen.
See required design:

<?xml version="1.0" encoding="utf-8"?>
<HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/horizontalScrollView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/scrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="0"
android:padding="5dp"
android:text="Sr. no"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_row="0"
android:padding="5dp"
android:text="Name owner address"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_row="0"
android:padding="5dp"
android:text="Sizes"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_row="0"
android:padding="5dp"
android:text="BHkk"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="0"
android:padding="5dp"
android:text="Call et.c."
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView6"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_row="2"
android:text="1" />
<TextView
android:id="#+id/textView7"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_column="2"
android:layout_row="2"
android:text="#string/dummyText" />
<TextView
android:id="#+id/textView8"
android:layout_width="39dp"
android:layout_height="wrap_content"
android:layout_column="3"
android:layout_row="2"
android:text="New Text" />
<TextView
android:id="#+id/textView9"
android:layout_width="20dp"
android:layout_height="wrap_content"
android:layout_column="4"
android:layout_row="2"
android:text="10dp" />
<TextView
android:id="#+id/textView10"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:layout_column="5"
android:layout_row="2"
android:text="New Text" />
</GridLayout>
</ScrollView>
</HorizontalScrollView>

Related

App shows a different activity layout when launched for the first time

I'm sorry for the confusion for the title but this is what happens
This is what the app looks like and it works fine.
HOWEVER...
When the app is launched everytime it shows this.
For some weird reason the card view stretches. This only happens everytime you open the app. It goes back to normal when you tap on assessment then go back.
I don't know what to do because my xml codes is all working as intended on the first photo and I don't know what causes this problem.
CODE:
<TextView
android:id="#+id/title_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="12dp"
android:text=" "
android:textColor="#fff"
android:fontFamily="#font/ness"
android:textSize="30sp"
android:textStyle="bold" />
<TextView
android:id="#+id/title_view2"
android:layout_width="294dp"
android:layout_height="58dp"
android:layout_below="#+id/title_view"
android:layout_alignParentStart="true"
android:layout_alignParentEnd="true"
android:layout_marginStart="65dp"
android:layout_marginTop="45dp"
android:layout_marginEnd="52dp"
android:layout_marginBottom="112dp"
android:fontFamily="#font/ness"
android:text="What do you want to do today?"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold" />
<GridLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#id/title_view"
android:layout_margin="100dp"
android:columnCount="2"
android:rowCount="3">
<androidx.cardview.widget.CardView
android:id="#+id/assess_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="0"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/asses" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Assessment"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/profile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_row="1"
android:layout_rowWeight="1"
android:layout_column="0"
android:layout_columnWeight="1"
android:layout_gravity="fill"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/profile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</GridLayout>
Do you need grid layout in this ui? And your android:columnCount="2" and android:rowCount="3" it's can be reason. Maybe you should use constraintlayout.
UPDATED
Try code below, maybe it can solve your problem.
Also I have seen you used RelativeLayout, for now day it's deprecated and google recommend to use constraintlayout.
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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">
<TextView
android:id="#+id/title_view2"
android:layout_width="294dp"
android:layout_height="58dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:fontFamily="#font/ness"
android:text="What do you want to do today?"
android:textAlignment="center"
android:textColor="#fff"
android:textSize="20sp"
android:textStyle="bold"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.cardview.widget.CardView
android:id="#+id/assess_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="#+id/title_view2"
app:layout_constraintStart_toStartOf="#+id/title_view2"
app:layout_constraintTop_toBottomOf="#+id/title_view2">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/asses" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Assessment"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
<androidx.cardview.widget.CardView
android:id="#+id/profile_menu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="fill"
android:layout_marginTop="8dp"
app:cardCornerRadius="8dp"
app:cardElevation="8dp"
app:cardUseCompatPadding="true"
app:layout_constraintEnd_toEndOf="#+id/assess_menu"
app:layout_constraintStart_toStartOf="#+id/assess_menu"
app:layout_constraintTop_toBottomOf="#+id/assess_menu">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:gravity="center"
android:orientation="vertical">
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/profile" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Profile"
android:textAlignment="center"
android:textStyle="bold" />
</LinearLayout>
</androidx.cardview.widget.CardView>
</androidx.constraintlayout.widget.ConstraintLayout>

how to make ImageView which is between two elements to margin left of the 'left element' using RelativeLayout?

What I want is to make the 'edit' ImageView between '6.4 MB' TextView and '···'TextView, and let 'edit' ImageView close to '···'TextView.
<RelativeLayout
android:layout_width="fill_parent"
android:layout_marginTop="15dp"
android:layout_height="match_parent">
<ImageView
android:src="#drawable/screenshot"
android:layout_width="80dp"
android:layout_height="80dp"
android:id="#+id/screenShot"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
/>
<TextView
android:text="Video Name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="23dp"
android:textColor="#000000"
android:id="#+id/videoName"
android:layout_toRightOf="#id/screenShot"
android:layout_alignParentTop="true"
/>
<TextView
android:text="2021.05.19 · 5:11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="#+id/recordDate"
android:layout_toRightOf="#id/screenShot"
android:layout_below="#id/videoName"
/>
<TextView
android:text="6.4 MB"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="15dp"
android:textColor="#797675"
android:id="#+id/videoSize"
android:layout_toRightOf="#id/screenShot"
android:layout_alignBottom="#id/screenShot"
/>
<ImageView
android:src="#drawable/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:id="#+id/edit"
android:layout_toRightOf="#id/videoSize"
android:layout_toLeftOf="#id/edit"
android:layout_alignBottom="#id/screenShot"
/>
<TextView
android:text="···"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:textSize="40dp"
android:textColor="#000000"
android:id="#+id/moreAction"
android:layout_alignBottom="#id/screenShot"
android:layout_alignParentRight="true"
/>
</RelativeLayout>
If I use android:layout_marginLeft="40dp" in 'edit' ImageView, then the 'edit' ImageView will disappear.
Why android:layout_marginLeft is noting working?
anyone can help?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/screenShot"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_alignParentLeft="true"
android:layout_marginRight="10dp"
android:src="#drawable/ic_launcher_background" />
<TextView
android:id="#+id/videoName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="Video Name"
android:textColor="#000000"
android:textSize="23dp" />
<TextView
android:id="#+id/recordDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/videoName"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="2021.05.19 · 5:11"
android:textColor="#797675"
android:textSize="15dp" />
<TextView
android:id="#+id/videoSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/screenShot"
android:layout_marginLeft="0dp"
android:layout_toRightOf="#id/screenShot"
android:text="6.4 MB"
android:textColor="#797675"
android:textSize="15dp" />
**<ImageView
android:id="#+id/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_alignBottom="#id/screenShot"
android:layout_marginRight="16dp"
android:layout_toLeftOf="#id/moreAction"
android:src="#drawable/ic_baseline_content_cut_24" />**
<TextView
android:id="#+id/moreAction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#id/screenShot"
android:layout_alignParentRight="true"
android:layout_marginLeft="0dp"
android:text="···"
android:textColor="#000000"
android:textSize="40dp" />
I shall remove
android:layout_toLeftOf="#id/edit"
and add
android:layout_marginLeft="170dp"
the complete 'edit' ImageView code is like below:
<ImageView
android:src="#drawable/edit"
android:layout_width="27dp"
android:layout_height="27dp"
android:id="#+id/edit"
android:layout_toRightOf="#id/videoSize"
android:layout_marginLeft="170dp"
android:layout_alignBottom="#id/screenShot"
/>

how to design responsive image button & layout by using android studio?

i am new to android development . I designed one parking app , but the layout is not responsive to all mobile devices.
I tried to make responsive image buttons by using 9patch png images & by taking different drawable folder(hdpi,mdpi,xhdpi) . But both are not working for large screen devices.
This is one sample xml file:
<?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/background"
>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/exit"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/exit1"
android:onClick="on_Bexit"
android:layout_alignTop="#+id/home0"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/home0"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/home1"
android:onClick="on_Bhome0"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/car"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:src="#drawable/c4"
android:onClick="on_Bcar"
android:cropToPadding="true"
android:nestedScrollingEnabled="true"
android:layout_alignBottom="#+id/textView5"
android:layout_alignLeft="#+id/bike"
android:layout_alignStart="#+id/bike" />
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bike"
android:layout_gravity="center_vertical"
android:src="#drawable/b3"
android:background="#android:color/transparent"
android:onClick="on_Bbike"
android:layout_above="#+id/exit"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="ENTRY "
android:id="#+id/textView"
android:textColor="#8dacbe"
android:textStyle="bold"
android:textSize="35dp"
android:layout_above="#+id/car"
android:layout_toLeftOf="#+id/textView6"
android:layout_toStartOf="#+id/textView6" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/bike_count"
android:text="90"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic"
android:layout_alignBottom="#+id/bike"
android:layout_toLeftOf="#+id/exit"
android:layout_toStartOf="#+id/exit"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/car_count"
android:text="120"
android:textStyle="bold|italic"
android:textColor="#140441"
android:textSize="30dp"
android:layout_alignBottom="#+id/car"
android:layout_alignRight="#+id/bike_count"
android:layout_alignEnd="#+id/bike_count" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="#+id/textView5"
android:visibility="invisible"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/T_areadis"
android:hint="Parking area id and name"
android:textColor="#8dacbe"
android:text="kharghar"
android:textSize="30dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="PAGE"
android:id="#+id/textView6"
android:textColor="#005384"
android:textSize="40dp"
android:textAlignment="center"
android:fontFamily="#string/abc_action_bar_home_description"
android:textStyle="bold"
android:layout_alignTop="#+id/textView"
android:layout_toRightOf="#+id/car_count"
android:layout_toEndOf="#+id/car_count" />
</RelativeLayout>
Please kindly help me out.
Large screen devices use xxhdpi.
How to has equal width
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/exit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bexit"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="ENTRY "
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#8dacbe"
android:textSize="35dp"
android:textStyle="bold" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/home0"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bhome0"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/bike_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="90"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/car"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bcar"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/car_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="120"
android:textColor="#140441"
android:textSize="30dp"
android:textStyle="bold|italic" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="vertical">
<ImageButton
android:id="#+id/bike"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="fitCenter"
android:layout_gravity="center_vertical"
android:background="#android:color/transparent"
android:onClick="on_Bbike"
android:src="#drawable/icon_login" />
<TextView
android:id="#+id/T_areadis"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="Parking area id and name"
android:text="kharghar"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#8dacbe"
android:textSize="30dp" />
</LinearLayout>

When editing text in editext it loses its focus and the keyboard show out so fast

My code works fine before I changed my layout from relative into linear layout in my xm file.What could be the cause of this? How can i fix this? I already tried some of I have researched here but nothing worked.Some says there something to put on manifest but it didn't work for me.Can you please help me out of this.
useritemdetail.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="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/Item"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:text="Item"
android:textSize="15dp" />
<TextView
android:id="#+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Item"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:textSize="15sp" />
<TextView
android:id="#+id/Quantity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/label"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:text="Quantity"
android:textSize="15dp" />
<EditText
android:id="#+id/inputQty"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Quantity"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:inputType="number"
android:textSize="12sp" >
<requestFocus />
</EditText>
<TextView
android:id="#+id/uom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/inputQty"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:text="UOM"
android:textSize="15dp" />
<Spinner
android:id="#+id/inputUom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/uom"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
/>
<TextView
android:id="#+id/Amount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/inputUom"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:text="Amount"
android:textSize="15dp" />
<TextView
android:id="#+id/inputAmt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/Amount"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:inputType="number"
android:textSize="12sp" />
<TextView
android:id="#+id/TotalAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/inputAmt"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:text="Total Amount"
android:textSize="15dp" />
<TextView
android:id="#+id/inputTamt"
android:layout_width="50dp"
android:layout_height="35dp"
android:layout_below="#+id/TotalAmount"
android:layout_marginTop="15sp"
android:layout_marginLeft="20sp"
android:textSize="12sp" />
</LinearLayout>

Android relative layout doesn't scroll

I have a relative layout in my xml file inside which I have another relative layout which has all my content. My Inner relative layout is loaded with content that comes from my database.
Also I have a edittext and button at bottom for adding comments.
Now the problem is that my inner relative layout doesn't scroll when the content is more but all the contents get hidden inside the bottom edit text and button.
Here is my xml.
<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="wrap_content"
android:background="#color/BG"
android:paddingTop="10dp" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
Now I want the inner relative layout’s height to occupy the whole screen and has to be
scrollable when content is more.Have a look at the image below.
Thanks in advance.
Wrap it in ScrollView
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scroll_view_layout">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#FFFFFF"
android:paddingLeft="15dp"
android:paddingRight="15dp"
android:paddingBottom="15dp"
android:scrollbars="vertical" >
<TextView
android:id="#+id/discTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginTop="20dp"
android:text="Title"
android:textColor="#77d3f1"
android:textSize="18sp" />
<TextView
android:id="#+id/discCategory"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discTitle"
android:layout_below="#+id/discTitle"
android:layout_marginTop="20dp"
android:text="Category"
android:textColor="#77d3f1"
android:textSize="14sp" />
<TextView
android:id="#+id/discDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discCategory"
android:layout_below="#+id/discCategory"
android:layout_marginTop="20dp"
android:text="Decsription"
android:textColor="#908484"
android:textSize="16sp" />
<TextView
android:id="#+id/discTime"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="#+id/discDescription"
android:layout_below="#+id/discDescription"
android:layout_marginTop="20dp"
android:text="yyyy mm dd hh:mm:ss"
android:textSize="10sp" />
</RelativeLayout>
<EditText
android:id="#+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_marginRight="60dp"
android:background="#drawable/commentbg"
android:ems="10"
android:hint="Type a comment..."
android:inputType="textMultiLine"
android:minHeight="40dp"
android:paddingLeft="10dp"
android:textStyle="italic" >
<requestFocus />
</EditText>
<Button
android:id="#+id/button1"
android:layout_width="61dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:background="#drawable/commentbg"
android:minHeight="40dp"
android:text="Send" />
</RelativeLayout>
</ScrollView>
To scroll content you need to add ScrollView. ScrollView will be parent of the layout that you want to scroll.
http://developer.android.com/reference/android/widget/ScrollView.html

Resources