how to push the textview down? - android

<?xml version="1.0" encoding="UTF-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="30dp" >
<
android:id="#+id/uconnecttitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="25dp"
android:layout_marginBottom="5dp"
android:scaleType="centerInside"
android:src="#drawable/icon_logo_uconnect" />
<EditText
android:id="#+id/pwdfield"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/username"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:paddingLeft = "10dip"
android:background="#drawable/edittext_background"
android:hint="Password"
android:password="true"
android:textColor="#ffffff"
android:textColorHint="#d0d0d0"
android:textSize="24sp"
android:singleLine="true"
android:imeOptions="actionDone"
/>
<EditText
android:id="#+id/username"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/pwdfield"
android:layout_below="#+id/uconnecttitle"
android:layout_marginTop="10dp"
android:paddingLeft = "10dip"
android:background="#drawable/edittext_background"
android:hint="Username"
android:textColor="#ffffff"
android:textColorHint="#d0d0d0"
android:textSize="24sp"
android:singleLine="true">
</EditText>
<TextView
android:id="#+id/TextVersionNum"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:textColor="#008000"
android:textSize="20sp"
android:text="#string/appVersionName"
android:visibility="gone"/>
<Button
android:id="#+id/loginbtn"
android:layout_width="140dp"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/pwdfield"
android:layout_below="#+id/pwdfield"
android:layout_marginTop="10dp"
android:background="#drawable/button_custom"
android:text="#string/loginButton"
android:textColor="#ffffff"
android:textSize="28sp"
/>
<TextView
android:id="#+id/UserAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/pwdfield"
android:layout_below="#+id/username"
android:text="dfgfdgdfg"
android:textColor="#B0171F"
android:visibility="gone" />
<TextView
android:id="#+id/PwdAlert"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/loginbtn"
android:layout_below="#+id/pwdfield"
android:text="dsfsdf"
android:textColor="#B0171F"
android:visibility="gone" />
<TextView
android:id="#+id/troubleLoggingIn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/loginbtn"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
android:text="#string/troubleLoggingIn"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#0645AD" />
</RelativeLayout>
I need to push TextVersionNum down, I tried android:layout_marginBottom="0" but it does not bring the item down to the bottom. How can I move TextVersionNum as close to the bottom screen as possible? I also tried to set the padding for troubleLoggingIn, android:layout_marginBottom="0" but I do not see anything happen.

TextVersionNum might not be at the absolute bottom because if the container's padding:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/relativelayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="30dp" >
Try to set padding of the relativeLayout only for the other margins (top, left and right).

Related

is there a way to set text in login box that can be edited

is there a way to set text in login box that can be edited this what I have when I change android:hint to android:text nothing shows
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:gravity="center" android:orientation="vertical" android:id="#id/rl_authenticate_vpn" android:background="#de12161e" android:layout_width="fill_parent" android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_centerInParent="true">
<androidx.cardview.widget.CardView android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_margin="20.0dip" app:cardCornerRadius="10.0dip">
<RelativeLayout android:background="#color/white" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerInParent="true">
<RelativeLayout android:id="#id/ll_expandable" android:background="#color/white" android:layout_width="fill_parent" android:layout_height="wrap_content">
<RelativeLayout android:id="#id/relative_title" android:layout_width="fill_parent" android:layout_height="60.0dip">
<TextView android:textSize="20.0sp" android:textColor="#color/black" android:gravity="center_vertical" android:id="#id/tv_movie_id" android:layout_width="wrap_content" android:layout_height="fill_parent" android:text="Connect3" android:lines="2" android:drawablePadding="7.0dip" android:layout_centerVertical="true" android:drawableStart="#drawable/parental_password_lock" android:fontFamily="#string/font_family_medium" android:layout_marginStart="25.0dip" android:layout_toStartOf="#id/iv_cancel" android:layout_alignParentStart="true" />
<ImageView android:id="#id/iv_cancel" android:tag="15" android:focusable="true" android:visibility="visible" android:nextFocusDown="#id/bt_resume" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerVertical="true" android:layout_marginEnd="20.0dip" android:layout_alignParentEnd="true" app:srcCompat="#drawable/ic_cancel" />
</RelativeLayout>
<ImageView android:id="#id/iv_div" android:background="#color/black" android:layout_width="fill_parent" android:layout_height="2.0px" android:layout_below="#id/relative_title" />
<RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_below="#id/iv_div">
<TextView android:textSize="20.0sp" android:textColor="#color/black" android:gravity="center_vertical" android:id="#id/et_description" android:layout_width="fill_parent" android:layout_height="45.0dip" android:layout_marginTop="10.0dip" android:layout_marginBottom="10.0dip" android:fontFamily="#string/font_family_regular" android:paddingStart="10.0dip" android:layout_marginStart="25.0dip" android:layout_marginEnd="25.0dip" />
<EditText android:textColorHint="#color/white" android:id="#id/tv_vpn_username" android:background="#drawable/selector_verify_password_fields" android:focusable="true" android:nextFocusDown="#id/tv_vpn_password" android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_marginBottom="10.0dip" android:hint="#string/username" android:layout_below="#id/et_description" android:fontFamily="#string/font_family_regular" android:textDirection="locale" android:paddingStart="10.0dip" android:layout_marginStart="30.0dip" android:layout_marginEnd="30.0dip" />
<EditText android:textColorHint="#color/white" android:id="#id/tv_vpn_password" android:background="#drawable/selector_verify_password_fields" android:focusable="true" android:nextFocusUp="#id/tv_vpn_username" android:nextFocusDown="#id/bt_save_and_connect" android:layout_width="fill_parent" android:layout_height="40.0dip" android:layout_marginTop="10.0dip" android:layout_marginBottom="10.0dip" android:hint="#string/password" android:layout_below="#id/tv_vpn_username" android:fontFamily="#string/font_family_regular" android:textDirection="locale" android:paddingStart="10.0dip" android:layout_marginStart="30.0dip" android:layout_marginEnd="30.0dip" />
<Button android:textSize="18.0sp" android:textColor="#color/white" android:id="#id/bt_save_and_connect" android:tag="1" android:background="#drawable/back_btn_effect" android:focusable="true" android:nextFocusUp="#id/tv_vpn_password" android:layout_width="200.0dip" android:layout_height="40.0dip" android:layout_marginTop="10.0dip" android:layout_marginBottom="20.0dip" android:text="#string/save_connect" android:layout_below="#id/tv_vpn_password" android:layout_marginStart="40.0dip" />
<Button android:textSize="18.0sp" android:textColor="#color/white" android:id="#id/bt_close" android:tag="2" android:background="#drawable/logout_btn_effect" android:focusable="true" android:nextFocusLeft="#id/bt_save_and_connect" android:nextFocusUp="#id/tv_vpn_password" android:layout_width="150.0dip" android:layout_height="40.0dip" android:layout_marginTop="10.0dip" android:layout_marginBottom="20.0dip" android:text="#string/close" android:layout_below="#id/tv_vpn_password" android:layout_marginEnd="40.0dip" android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</RelativeLayout>
</RelativeLayout>
Change height to wrapcontent
android:layout_height="wrap_content"
and change hint to text
when I implement your way. I can see only one pixel of text when typing something

How to put an element on the right of some rows in RelativeLayout?

i created this layout for my list rows:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/press_event" >
<LinearLayout
android:id="#+id/viewNameM"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/orange_button_pressed" >
<TextView
android:id="#+id/nameUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#f6911e"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="#+id/viewDetails1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/viewNameM"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/catUser"
android:layout_alignParentRight="true"
android:layout_alignTop="#+id/catUser"
android:contentDescription="#string/arrowS"
android:src="#drawable/arrow" />
<TextView
android:id="#+id/catUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<RatingBar
android:id="#+id/ratingUser"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="#+id/arrow"
android:layout_marginRight="20dp"
android:layout_marginBottom="3dp"
android:layout_alignBottom="#+id/catUser"
android:indeterminate="false"
android:isIndicator="true"
android:numStars="#integer/five"
android:stepSize="0.1" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/viewDetails2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/viewDetails1"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<TextView
android:id="#+id/cityUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:textStyle="bold"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<TextView
android:id="#+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
Here is the output:
I would like to keep the arrow on the right of the rows, but i would to set it in the middle, like this:
I make several tries, but i cannot reach my goal. How to do that?
Thank you in advance.
Just do it like you would in real life:
Place caret on the right.
Place rating on the left of the caret, below separating line.
Place distance to the left of the caret, below rating.
...
<?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="#ffffff" >
<LinearLayout
android:id="#+id/viewNameM"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#cccccc" >
<TextView
android:id="#+id/nameUser"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#f6911e"
android:textStyle="bold" />
</LinearLayout>
<RelativeLayout
android:id="#+id/viewDetails1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/viewNameM"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" >
<ImageView
android:id="#+id/arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:src="#drawable/chevron" />
<TextView
android:id="#+id/catUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Hotel"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<RatingBar
android:id="#+id/ratingUser"
style="?android:attr/ratingBarStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/arrow"
android:layout_marginBottom="3dp"
android:layout_alignBottom="#+id/catUser"
android:indeterminate="false"
android:isIndicator="true"
android:numStars="5"
android:stepSize="0.1" />
<TextView
android:id="#+id/cityUser"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#id/catUser"
android:textStyle="bold"
android:text="Roma"
android:layout_marginBottom="3dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#4a4c4d" />
<TextView
android:id="#+id/distance"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="#+id/arrow"
android:layout_below="#id/ratingUser"
android:textColor="#4a4c4d"
android:text="22km"
android:textAppearance="?android:attr/textAppearanceMedium" />
</RelativeLayout>
</RelativeLayout>
This is looks like you want.
Create layout of this type using Layout weight in LinnerLayout

EditText disappeared after being placed in a linear layout

When i placed my edit text into a linear layout to stop it from lagging is disappeared from the app screen and now my app crashes when its launched.(the ending of the code such as /linearLayout> is there it just wont show up on here)
old code:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.trucktracker.MainActivity"
android:background="#drawable/background"
tools:ignore="MergeRootFrame">
<Button
android:id="#+id/continuebtn"
android:layout_width="match_parent"
android:layout_height="68dp"
android:layout_alignParentBottom="true"
android:onClick="clickedContinue"
android:text="#string/continue_btn"
android:textColor="#ffffff"
android:background="#drawable/btnbackreg"
android:layout_marginRight="7dp"
android:layout_marginLeft="7dp"
android:layout_marginTop="3dp"
android:layout_marginBottom="3dp"
android:textSize="30sp" />
<ImageView
android:id="#+id/legion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentTop="true"
android:layout_marginBottom="262dp"
android:layout_marginRight="105dp"
android:contentDescription="#string/logo"
android:src="#drawable/legion" />
<TextView
android:id="#+id/question"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/continuebtn"
android:layout_alignParentLeft="true"
android:layout_marginBottom="162dp"
android:text="#string/question1"
android:textSize="19sp"
android:textColor="#ffffff"
tools:context=".MainActivity" />
<EditText
android:id="#+id/Phonesignup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/continuebtn"
android:layout_alignParentLeft="true"
android:layout_marginBottom="65dp"
android:ems="10"
android:hint="#string/phonesignup"
android:inputType="phone"
android:textColorHint="#ffffff"
android:textColor="#ffffff"
android:textSize="20sp" >
</EditText>
<Spinner
android:id="#+id/optionselect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/Phonesignup"
android:layout_alignTop="#+id/question"
android:layout_marginBottom="45dp"
android:layout_marginLeft="18dp"
android:textColor="#b32017"
android:layout_toRightOf="#+id/question" />
new code:
<linearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<EditText
android:id="#+id/Phonesignup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="65dp"
android:ems="10"
android:hint="#string/phonesignup"
android:inputType="phone"
android:textColor="#ffffff"
android:textColorHint="#ffffff"
android:textSize="20sp" />
You typed the wrong tag for opening a LinearLayout. It should be a capital 'L', not a lowercase 'l'. Also, you need to set the orientation of a LinearLayout to either vertical or horizontal:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" (or horizontal)
>

Android RelativeLayout align element on another elements border

Im trying to make a text view to align to the left border of another imageview in a RelativeLayout, but I'm having trouble and I cannot achieve this. Can anyone tell me how can I achieve this?
Here is my current XML layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="15dp"
android:orientation="vertical" >
<ImageView
android:id="#+id/main_item_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY" />
<RelativeLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#drawable/blackalha"
android:gravity="center_vertical"
android:orientation="horizontal"
android:weightSum="100" >
<TextView
android:id="#+id/main_item_cont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/main_item_nmb"
android:paddingLeft="5dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
<ImageView
android:id="#+id/main_item_ic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:background="#color/app_purple"
android:src="#drawable/bacal" />
<TextView
android:id="#+id/main_item_nmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="#+id/main_item_ic"
android:background="#drawable/saric"
android:gravity="center"
android:textColor="#333333" />
</RelativeLayout>
<TextView
android:id="#+id/main_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/main_item_bg"
android:layout_margin="5dp"
android:maxWidth="200dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
</RelativeLayout>
Try this
<?xml version="1.0" encoding="utf-8"?>
<ImageView
android:id="#+id/main_item_bg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:contentDescription="#string/app_name"
android:scaleType="fitXY" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="80dip"
android:gravity="center"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<TextView
android:id="#+id/main_item_cont"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:gravity="center"
android:paddingLeft="5dp"
android:text="dsgffdufsdfdfsdfdsfsdfsdfdsfdf"
android:inputType="textMultiLine"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
<ImageView
android:id="#+id/main_item_ic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="5dip"
android:layout_alignParentRight="true"
android:layout_toRightOf="#+id/main_item_cont"
android:background="#android:color/black"
android:src="#drawable/ic_launcher" />
<TextView
android:id="#+id/main_item_nmb"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/main_item_cont"
android:layout_toRightOf="#+id/main_item_cont"
android:background="#android:color/white"
android:text="10"
android:textColor="#android:color/white" />
</RelativeLayout>
<TextView
android:id="#+id/main_item_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignTop="#+id/main_item_bg"
android:layout_margin="5dp"
android:maxWidth="200dp"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#android:color/white" />
As #Salauyou mentioned, try with android:layout_alignLeft because it "Makes the left edge of this view match the left edge of the given anchor view ID"
and android:layout_toLeftOf means "Positions the right edge of this view to the left of the given anchor view ID."
Now, this is what I achieved:
I used this picture in drawable-mdpi (as the badge) - note the trick of the dual background:
and the standard launcher icon, since I didn't have a wine glass icon handy.
This is my layout:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fff"
android:layout_margin="0dp"
android:padding="0dp"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="0dp"
android:padding="4dp"
>
<TextView
android:id="#+id/txtIcon"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_alignParentRight="true"
android:gravity="center"
android:padding="4dp"
android:background="#6b2339"
android:drawableRight="#drawable/ic_launcher"
/>
<TextView
android:id="#+id/txtBadge"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_toLeftOf="#id/txtIcon"
android:gravity="center"
android:padding="4dp"
android:background="#drawable/wines_crossing_badge"
android:text="8"
android:textColor="#312c23"
android:textSize="16sp"
/>
<TextView
android:id="#+id/txtDesc"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#id/txtBadge"
android:background="#312c23"
android:gravity="left|center_vertical"
android:padding="4dp"
android:text="Available Androids in stock for rental"
android:textColor="#fff"
android:textSize="16sp"
/>
</RelativeLayout>
</RelativeLayout>

Incorrect layout when keyboard is shown

I have TextView in RelativeLayout, which works properly:
<TextView
android:id="#+id/tv_client_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/tv_label_client_out"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv_label_client_in"
android:background="#drawable/border"
android:ems="10" />
Now I need to place this TextView inside of ScrollView:
<ScrollView android:id="#+id/sv_client_in"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="#+id/tv_label_client_out"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv_label_client_in"
android:background="#drawable/border"
android:fillViewport="true"
>
<TextView
android:id="#+id/tv_client_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
/>
</ScrollView>
After this change layout looks OK (first image), but when keyboard is shown, it is corrupted (second image). How can I fix this?
Full layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/tv_label_client_host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginTop="20dp"
android:ems="10"
android:text="#string/label_host" />
<EditText
android:id="#+id/et_client_host"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv_label_client_host"
android:ems="10"
android:inputType="text"
android:lines="1" />
<TextView
android:id="#+id/tv_label_client_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/et_client_host"
android:ems="10"
android:text="#string/label_port" />
<EditText
android:id="#+id/et_client_port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv_label_client_port"
android:ems="10"
android:inputType="number"
android:lines="1" />
<ScrollView android:id="#+id/sv_client_in"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_above="#+id/tv_label_client_out"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/tv_label_client_in"
android:background="#drawable/border"
android:fillViewport="true"
>
<TextView
android:id="#+id/tv_client_in"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ems="10"
/>
</ScrollView>
<Button
android:id="#+id/btn_client_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:text="#string/btn_send"
android:onClick="OnBtnSendClick"
/>
<TextView
android:id="#+id/tv_label_client_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/btn_client_send"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:ems="10"
android:text="#string/label_client_out" />
<EditText
android:id="#+id/et_client_out"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_toLeftOf="#+id/btn_client_send"
android:ems="10"
android:inputType="text"
android:lines="1" />
<Button
android:id="#+id/btn_client_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/et_client_port"
android:text="#string/btn_client_clear"
android:onClick="OnBtnClearClick"
/>
<Button
android:id="#+id/btn_client_disconnect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/et_client_port"
android:text="#string/btn_client_disconnect"
android:onClick="OnBtnDisconnectClick"
/>
<Button
android:id="#+id/btn_client_connect"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/et_client_port"
android:layout_toLeftOf="#+id/btn_client_disconnect"
android:text="#string/btn_client_connect"
android:onClick="OnBtnConnectClick"
/>
<TextView
android:id="#+id/tv_label_client_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="#+id/btn_client_connect"
android:ems="10"
android:text="#string/label_client_in"
/>
</RelativeLayout>
This happens mainly because of the views aligning to bottom. You have aligned them to bottom, so when the keyboard pops up the bottom changes hence the Views associated with it.
Try checking your xml file.
The problem is solved by using LinearLayout.

Categories

Resources