In order to view all the elements inside my relativelayout in smaller screens, I have made the choice to use a scrollview to make it possible (or at least to try to accomplish this). The problem: I'm unable to scroll. The result of having or not the scrollview is the same, if the screen is small some elements will get cut off (this was fine if scroll was possible). In some searches I have come across some scrollview with linearlayout implementations, but in my case I think it's not very good, because i need check boxes aligned to the right of text.
Heres the xml of what I got thus far:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#231E1A"
android:keepScreenOn="true"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:ignore="ContentDescription"
android:fillViewport="true">
<RelativeLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btn_getDirections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:text="#string/btn_getDirections" />
<TextView
android:id="#+id/static_language"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/radioGroup"
android:layout_alignLeft="#+id/radioGroup"
android:text="#string/static_language"
android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<AutoCompleteTextView
android:id="#+id/aComplete_destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/static_language"
android:layout_alignLeft="#+id/static_language"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="#string/aComplete_destination" />
<TextView
android:id="#+id/static_destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/aComplete_destination"
android:layout_alignLeft="#+id/aComplete_destination"
android:text="#string/static_destination"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<TextView
android:id="#+id/static_highways"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/static_destination"
android:layout_alignLeft="#+id/static_destination"
android:paddingBottom="10dp"
android:text="#string/static_highways"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<TextView
android:id="#+id/static_tolls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/static_highways"
android:layout_alignLeft="#+id/static_highways"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/static_tolls"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<TextView
android:id="#+id/static_useCurrentLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/static_tolls"
android:layout_alignLeft="#+id/static_tolls"
android:paddingTop="10dp"
android:text="#string/static_useCurrentLocation"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<AutoCompleteTextView
android:id="#+id/aComplete_origin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/static_useCurrentLocation"
android:layout_alignLeft="#+id/static_useCurrentLocation"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="#string/aComplete_origin" >
<requestFocus />
</AutoCompleteTextView>
<TextView
android:id="#+id/static_origin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/aComplete_origin"
android:layout_alignLeft="#+id/aComplete_origin"
android:text="#string/static_origin"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<ImageView
android:id="#+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/static_origin"
android:layout_alignLeft="#+id/static_origin"
android:layout_alignParentTop="true"
android:paddingBottom="10dp"
android:scaleType="fitStart"
android:src="#drawable/logo" />
<CheckBox
android:id="#+id/tolls_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_tolls"
android:layout_alignBottom="#+id/static_tolls"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
<CheckBox
android:id="#+id/highways_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_highways"
android:layout_alignBottom="#+id/static_highways"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
<CheckBox
android:id="#+id/useLocation_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_useCurrentLocation"
android:layout_alignBottom="#+id/static_useCurrentLocation"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/btn_getDirections"
android:layout_alignLeft="#+id/btn_getDirections"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:textColor="#FFFFFF"
android:layout_marginRight="20dp"
android:text="#string/radio_english" />
<RadioButton
android:id="#+id/radio_portugues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text="#string/radio_portugues" />
</RadioGroup>
</RelativeLayout>
</ScrollView>
Huzzah! I got it to work! It was all a combination, of linearlayout, scrollview and relativelayout were was needed. Now it scrolls perfectly when the screen its not big enough to view the full content. I'm guessing that changing to linearlayout, was in fact the key in this. Basically i applied what was stated in developer site: http://developer.android.com/reference/android/widget/ScrollView.html
A child that is often used is a LinearLayout in a vertical
orientation, presenting a vertical array of top-level items that the
user can scroll through.
The xml:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#231E1A"
android:keepScreenOn="true"
android:scrollbars="none"
android:overScrollMode="never"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:ignore="ContentDescription"
android:fillViewport="true">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="bottom"
android:keepScreenOn="true"
android:orientation="vertical" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="80dp"
android:id="#+id/logo"
android:scaleType="fitStart"
android:src="#drawable/logo"/>
<TextView
android:id="#+id/static_origin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/static_origin"
android:paddingTop="10dp"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FFFFFF" />
<AutoCompleteTextView
android:id="#+id/aComplete_origin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="#string/aComplete_origin" >
<requestFocus />
</AutoCompleteTextView>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/static_useCurrentLocation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:paddingTop="10dp"
android:text="#string/static_useCurrentLocation" />
<TextView
android:id="#+id/static_tolls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/static_useCurrentLocation"
android:layout_below="#+id/static_useCurrentLocation"
android:textColor="#FFFFFF"
android:textSize="20sp"
android:paddingBottom="10dp"
android:paddingTop="10dp"
android:text="#string/static_tolls" />
<TextView
android:id="#+id/static_highways"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/static_tolls"
android:layout_alignLeft="#+id/static_tolls"
android:paddingBottom="10dp"
android:text="#string/static_highways"
android:textColor="#FFFFFF"
android:textSize="20sp" />
<CheckBox
android:id="#+id/tolls_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_tolls"
android:layout_alignBottom="#+id/static_tolls"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
<CheckBox
android:id="#+id/highways_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_highways"
android:layout_alignBottom="#+id/static_highways"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
<CheckBox
android:id="#+id/useLocation_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/static_useCurrentLocation"
android:layout_alignBottom="#+id/static_useCurrentLocation"
android:layout_alignParentRight="true"
android:text="#string/checkbox" />
</RelativeLayout>
<TextView
android:id="#+id/static_destination"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/static_destination"
android:textColor="#FFFFFF"
android:textAppearance="?android:attr/textAppearanceLarge" />
<AutoCompleteTextView
android:id="#+id/aComplete_destination"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:inputType="textNoSuggestions"
android:text="#string/aComplete_destination" />
<TextView
android:id="#+id/static_language"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/static_language"
android:textColor="#FFFFFF"
android:textAppearance="?android:attr/textAppearanceLarge" />
<RadioGroup
android:id="#+id/radioGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:id="#+id/radio_english"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:textColor="#FFFFFF"
android:layout_marginRight="20dp"
android:text="#string/radio_english" />
<RadioButton
android:id="#+id/radio_portugues"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#FFFFFF"
android:text="#string/radio_portugues" />
</RadioGroup>
<Button
android:id="#+id/btn_getDirections"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/btn_getDirections" />
</LinearLayout>
</ScrollView>
Related
This is my relative layout right now:
http://prntscr.com/d9yure
All I want is deleteList be under the deleteUsersTxt, but it doesn't let me. It only allows me to put it below invitation list. I have tried to add to it android:layout_below="#+id/deleteUsersTxt" but it just makes it dissapear.
This is the 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="match_parent" android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
android:paddingBottom="#dimen/activity_vertical_margin"
tools:context="meet.projectoklahoma.Activities.CreateEventActivity">
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/invitaionsList"
android:layout_above="#id/deleteUsersTxt"
android:choiceMode="multipleChoice"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/addUsersTxt" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/other"
android:id="#+id/otherButton"
android:onClick="setDate"
android:layout_alignTop="#+id/tomorrowButton"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/which_day"
android:id="#+id/whichDayTxt"
android:layout_below="#+id/eventNameTextBox"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/tomorrow"
android:id="#+id/tomorrowButton"
android:onClick="tomorrow"
android:layout_alignTop="#+id/todayButton"
android:layout_toRightOf="#+id/otherButton"
android:layout_toEndOf="#+id/otherButton" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="whichDay"
android:id="#+id/dayTxt"
android:layout_below="#+id/whichDayTxt"
android:layout_alignRight="#+id/whichDayTxt"
android:layout_alignEnd="#+id/whichDayTxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="date"
android:id="#+id/dateTxt"
android:layout_below="#+id/dayTxt"
android:layout_alignRight="#+id/dayTxt"
android:layout_alignEnd="#+id/dayTxt" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/which_time"
android:id="#+id/timeTxt"
android:layout_below="#+id/dateTxt"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/choose_time"
android:id="#+id/whichTimeBtn"
android:layout_alignTop="#+id/timeTxt"
android:layout_alignLeft="#+id/todayButton"
android:layout_alignStart="#+id/todayButton"
android:onClick="setTime"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="whichTime"
android:id="#+id/whichTimeTxt"
android:layout_below="#+id/timeTxt"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="#string/add_users_to_event"
android:id="#+id/addUsersTxt"
android:layout_below="#+id/whichTimeBtn"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/today"
android:id="#+id/todayButton"
android:onClick="today"
android:layout_alignBottom="#+id/dayTxt"
android:layout_toLeftOf="#+id/timeTxt"
android:layout_toStartOf="#+id/timeTxt" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/eventNameTextBox"
android:text="שם האירוע"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<TextView
android:text="הסרת משתמשים מהאירוע:"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/deleteUsersTxt"
android:layout_marginBottom="131dp"
android:layout_above="#+id/cancelAndDeleteButton"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/delete_and_cancel"
android:id="#+id/cancelAndDeleteButton"
android:onClick="deleteEvent"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="סבבה"
android:id="#+id/SaveEventButton"
android:onClick="editEvent"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ListView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/deleteList"
android:layout_below="#+id/invitaionsList"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
Is there a minimum space for a list to be in?
Here is not something but everything goes wrong.
You can use LinearLayout (with vertical orientation) as your root layout to make it easy.
Then it will become more easy to understand for you.
Try grouping them inside of a LinearLayout and split them equally, like this:
<LinearLayout
android:layout_width="match_parent"
android:orientation="vertical"
android:layout_above="#id/deleteUsersTxt"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/addUsersTxt"
android:layout_height="wrap_content">
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:id="#+id/invitaionsList"
android:layout_weight="1"
android:choiceMode="multipleChoice" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/deleteList"/>
</LinearLayout>
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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">
<include layout="#layout/toolbar"/>
<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_height="wrap_content"
android:layout_above="#+id/makeOffer"
android:fillViewport="true">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.CardView
android:id="#+id/firstcard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
android:layout_marginTop="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<RelativeLayout
android:id="#+id/insidecardone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/constant_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/padding_4dp"
android:text="Charge per day"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/tvRentPerday"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:hint="Rs. "
android:gravity="center"
android:inputType="number"
android:maxLength="4"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/insidecardtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardone"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/con_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Duration (Days)"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/num_days"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center_horizontal"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_24dp"
android:text="10"
android:textSize="#dimen/text_size_big_16"
/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_8dp"
android:background="#color/grey_lighter" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_4dp"
android:paddingBottom="#dimen/padding_8dp"
android:paddingTop="#dimen/padding_24dp">
<TextView
android:id="#+id/total_constant"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/padding_4dp"
android:gravity="center_vertical"
android:text="Total Amount"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/tvAmount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center_vertical"
android:textColor="#ff4f00"
android:textSize="#dimen/text_size_big_16"
android:textStyle="bold" />
<TextView
android:id="#+id/total_constant_mutterfly"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/total_constant"
android:paddingTop="#dimen/padding_4dp"
android:text="#string/process_fee_text"
android:textColor="#android:color/darker_gray"
android:textSize="8sp" />
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/middlecard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/firstcard"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<RelativeLayout
android:id="#+id/middlecard_relative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_margin="#dimen/padding_4dp">
<TextView
android:id="#+id/deposite"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="#dimen/padding_4dp"
android:gravity="center_vertical"
android:text="Deposit"
android:textSize="#dimen/text_size_big_16" />
<TextView
android:id="#+id/knowmore"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/deposite"
android:text="#string/txt_know_more"
android:layout_marginTop="#dimen/padding_8dp"
android:textSize="#dimen/text_size_extra_extra_small_10"
/>
<CheckBox
android:id="#+id/checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:inputType="number"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
<RelativeLayout
android:id="#+id/middletwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/middlecard_relative"
android:layout_margin="#dimen/padding_4dp"
android:visibility="gone"
>
<TextView
android:id="#+id/middle_con_duration"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Charge (Rs.)"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/etDeposit"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:gravity="center"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:hint="1000"
android:maxLength="4"
android:inputType="number"
android:textSize="#dimen/text_size_big_16"
/>
</RelativeLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/seccard"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/middlecard"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
app:cardCornerRadius="#dimen/padding_4dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:orientation="vertical">
<TextView
android:id="#+id/describe_constant_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="#dimen/padding_8dp"
android:text="Describe Your item"
android:textColor="#ff4f00"
android:textStyle="bold" />
<RelativeLayout
android:id="#+id/rlTohide"
android:layout_marginTop="#dimen/padding_4dp"
android:layout_width="160dp"
android:layout_height="120dp"
android:background="#drawable/greyborder_transparentbg"
>
<ImageView
android:id="#+id/img1"
android:layout_centerInParent="true"
android:layout_width="40dp"
android:src="#drawable/addimg"
android:layout_height="40dp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/img1"
android:text="(Optional)"
android:textSize="#dimen/text_size_extra_extra_small_10"
android:textColor="#color/text_grey_opc"
android:layout_centerInParent="true"
/>
</RelativeLayout>
<ImageView
android:visibility="gone"
android:id="#+id/imgResource"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_gravity="center"
android:layout_marginTop="#dimen/padding_8dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp"
android:layout_marginTop="180dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardone"
android:layout_margin="#dimen/padding_4dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<TextView
android:id="#+id/con_product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_marginTop="8dp"
android:text="Name Of Product"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/product_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_toEndOf="#+id/con_product_name"
android:layout_toRightOf="#+id/con_product_name"
android:layout_alignParentRight="true"
android:hint="E.g. Nikon DSLR"
android:paddingEnd="#dimen/padding_16dp"
android:paddingRight="#dimen/padding_16dp"
android:maxLength="30"
android:inputType="textPersonName"
android:layout_marginLeft="#dimen/padding_16dp"
android:layout_marginStart="#dimen/padding_16dp"
android:textColor="#android:color/black"
android:textSize="#dimen/text_size_big_16"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/insidecardtwo"
android:layout_margin="#dimen/padding_4dp"
android:layout_marginBottom="#dimen/padding_8dp"
android:layout_marginLeft="#dimen/padding_8dp"
android:layout_marginRight="#dimen/padding_8dp">
<TextView
android:id="#+id/Description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="Description :"
android:textSize="#dimen/text_size_big_16" />
<EditText
android:id="#+id/desc_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/Description"
android:hint="E.g. Comes with 18-55 mm lens, charger and carry case"
android:layout_marginTop="#dimen/padding_8dp"
android:background="#drawable/white_border_request_screen"
android:textColor="#android:color/darker_gray"
android:textSize="#dimen/text_size_big_16" />
</RelativeLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</RelativeLayout>
</ScrollView>
<Button
android:id="#+id/makeOffer"
android:layout_width="match_parent"
android:layout_height="#dimen/padding_48dp"
android:layout_alignParentBottom="true"
android:background="#color/new_primary_text"
android:padding="#dimen/padding_8dp"
android:text="#string/txt_make_offr"
android:textColor="#android:color/white"
android:textSize="#dimen/text_size_18"
/>
</RelativeLayout>
Android Manifest
<activity
android:name=".MyActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustResize"/>
I am working on the layout since last night and I tried almost solution which I known. I am new in Android so please suggest me what is wrong with this layout.
this "fillViewport" work for another screen but with this screen it's not working.
Add android:windowSoftInputMode="stateHidden|adjustResize" to your <activity> tag in AndroidManifest.xml file. This will cause the screen to be resized to the left over space after the soft keyboard is shown. So, you will be able to scroll easily.
One more thing set property of ScrollView to the android:layout_above to the Button on the bottom of the page.
UpDate :
add this line to your ScrollView.
android:layout_above="#+id/makeOffer"
like this way
<ScrollView
android:id="#+id/scroll"
android:layout_width="wrap_content"
android:layout_below="#+id/toolbar"
android:layout_height="wrap_content"
android:fillViewport="true"
android:layout_above="#+id/makeOffer">
ScreenShot :
I design a xml( in layout package) in android project, I want my UI run on any android mobile and android tablet, if size of device change my UI shows good, I use LinearLayout for each group, in linearLayout3 I have one textview and one EditText, when I run program I get error from my textview and EditText in linearLayout3,error is:
“Binary XML file line #90: Error inflating class android.widget.EditText”
Please suggest to me a solution for resolving my problem.
Code is:
<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:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivitytest" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/btnstop"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:drawableTop="#drawable/r_stop"
android:text="Stop" />
<Button
android:id="#+id/btnstart"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="140dp"
android:drawableTop="#drawable/r_start"
android:text="Start" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout1">
<RadioGroup
android:id="#+id/radioGroup3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:ems="150"
android:gravity="right" >
<RadioButton
android:id="#+id/Rb_Defualt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:ems="150"
android:gravity="right"
android:text="testdefualt"/>
<RadioButton
android:id="#+id/Rb_Periodic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="150"
android:gravity="right"
android:text="testperiodic"/>
<RadioButton
android:id="#+id/Rb_Maual"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="150"
android:fitsSystemWindows="true"
android:gravity="right"
android:text="testmanual"
android:visibility="visible" />
</RadioGroup>
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout2" >
<TextView
android:id="#+id/TxtTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ems="200"
android:textIsSelectable="true"
android:text="Please Enter Time"/>
<EditText
android:id="#+id/Txt_Minute_Periodic"
android:layout_width="0dip"
android:layout_marginLeft="-300dp"
android:layout_height="wrap_content"
android:paddingBottom="#+id/TxtTime"
android:layout_weight="50"
android:layout_marginTop="50dp"
android:inputType="number" />
</LinearLayout>
<LinearLayout
android:id="#+id/linearLayout4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/linearLayout3"
android:layout_marginTop="60dp">
<Button
android:id="#+id/btn_ok"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:drawableTop="#drawable/r_ok"
android:text="ok" />
<Button
android:id="#+id/btn_Config"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="30dp"
android:drawableTop="#drawable/r_config"
android:text="config" />
<Button
android:id="#+id/btnkeyManagment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="17dp"
android:drawableTop="#drawable/r_save"
android:maxLines="2"
android:text="key" />
</LinearLayout>
</RelativeLayout>
The android:paddingBottom field in your EditText should be a number and not an id.
I am trying to reduce the space between 2 columns, have tried using negative margins, but did not work. Is there a way to bring the 2 elements in the image closer ?
<?xml version="1.0" encoding="utf-8"?>
<GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:useDefaultMargins="true"
android:alignmentMode="alignBounds"
android:columnOrderPreserved="false"
android:layout_gravity="center"
android:orientation="horizontal"
android:stretchMode="columnWidth"
android:background="#color/orange"
android:textSize="12sp"
android:columnCount="8">
<ImageButton
android:id="#+id/settings"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="1"
android:layout_gravity="left"
android:src="#drawable/settings" />
<TextView
android:id="#+id/currentCityName"
android:layout_column="2"
android:textSize="22sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="City name"
android:layout_columnSpan="4"
android:layout_gravity="center_horizontal"
/>
<ImageButton
android:id="#+id/refresh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="7"
android:layout_columnSpan="1"
android:layout_gravity="right"
android:src="#drawable/reload" />
<ImageView
android:id="#+id/currentWeatherImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_columnSpan="8"
android:layout_rowSpan="3"
android:layout_gravity="center_horizontal"
android:src="#drawable/cloud" />
<ImageView
android:id="#+id/humidityIcon"
android:layout_width="20dp"
android:paddingTop="10dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:layout_marginRight="0dp"
android:layout_gravity="left"
android:background="#000000"
android:src="#drawable/humidity" />
<TextView
android:id="#+id/humidity"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="13sp"
android:paddingTop="10dp"
android:paddingLeft="0dp"
android:layout_marginLeft="0dp"
android:layout_gravity="left"
android:background="#FFFFFF"
/>
<TextView
android:id="#+id/temperature"
android:layout_columnSpan="4"
android:layout_rowSpan="2"
android:textSize="49sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="5dp"
android:layout_gravity="center_horizontal"/>
<ImageView
android:id="#+id/windSpeedIcon"
android:layout_width="30dp"
android:layout_marginRight="1dp"
android:paddingRight="1dp"
android:layout_gravity="right"
android:src="#drawable/wind" />
<TextView
android:id="#+id/windSpeed"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
/>
<!-- android:layout_width="40dp" -->
<TextView
android:id="#+id/precipitationIcon"
android:textSize="28sp"
android:layout_width="40dp"
/>
<TextView
android:id="#+id/precipitation"
android:layout_column="0"
android:textSize="13sp"
android:layout_width="40dp"
/>
<TextView
android:id="#+id/windDirection16Point"
android:textSize="13sp"
android:layout_width="80dp"
android:layout_columnSpan="2"
/>
<TextView
android:id="#+id/weatherDescription"
android:layout_gravity="center_horizontal"
android:layout_row="7"
android:layout_columnSpan="8"/>
<TextView
android:id="#+id/section_label"
android:layout_margin="5dp"
android:layout_columnSpan="8" />
<EditText
android:minLines="4"
android:maxLines="4"
android:id="#+id/edit"
android:layout_columnSpan="8"/>
I suggest implementing the entire view using a RelativeLayout, should be the best solution for the entire view.
You are tackling the wrong problem – you are asking how to reduce the space between columns in a grid layout, but maybe you should’t have used such a layout in the first place!
What you should have been using for your specific layout, is a combination of relative positioning and compound drawables (here, with android:drawableStart).
<?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="80dp"
android:background="#d89018"
android:paddingBottom="4dp"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:paddingTop="4dp"
>
<TextView
android:id="#+id/temperature"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:text="25 ℃"
android:textColor="#fff"
android:textSize="49sp"
/>
<TextView
android:id="#+id/humidity"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:drawableStart="#drawable/humidity"
android:gravity="center_vertical"
android:text="83 %"
android:textColor="#fff"
/>
<TextView
android:id="#+id/windSpeed"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:drawableStart="#drawable/wind"
android:gravity="center_vertical"
android:text="19 km/h"
android:textColor="#fff"
/>
<TextView
android:id="#+id/precipitation"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentStart="true"
android:drawableStart="#drawable/precipitation"
android:gravity="center_vertical"
android:text="0.1 mm"
android:textColor="#fff"
/>
<TextView
android:id="#+id/windDirection16Point"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_alignLeft="#id/windSpeed"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:drawableStart="#drawable/windDirection"
android:gravity="center_vertical"
android:text="NNW"
android:textColor="#fff"
/>
</RelativeLayout>
Not only this layout is simpler, you also let Android take care of all the spacing for you. To change the spacing between the compound drawable and the text, use android:drawablePadding in the layout’s code above; in Java code, that would be TextView.setCompoundDrawablePadding).
Icons used for the sample: water, windsock, rainy-weather and wind-rose.
I think what's happening is that your Views are being stretched because they are trying to match the width of another view in their columns.
Try decreasing the columnSpan of your Views or separate your layout into two separate GridLayouts.
Or, consider using a different layout altogether. I would recommend RelativeLayout here instead of GridLayout, but I don't know how this fits into a larger window.
try this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp">
<LinearLayout
android:id="#+id/col1"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.4"
>
<LinearLayout
android:id="#+id/col1_row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="83%"/>
</LinearLayout>
<LinearLayout
android:id="#+id/col1_row2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1.0mm"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:id="#+id/col2"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.0"
android:gravity="center"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="25'"
android:textSize="50dp"
/>
</LinearLayout>
<LinearLayout
android:id="#+id/col3"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:layout_weight="2.4"
>
<LinearLayout
android:id="#+id/col3_row1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="19Km"/>
</LinearLayout>
<LinearLayout
android:id="#+id/col3_row2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/icon"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="NNW"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
I think you should change usedefaultMargins to false and give your own margins to the elements.
android:useDefaultMargins="false";
I have a scroll view:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="500dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/antiquewhiter"
android:weightSum="100"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:background="#drawable/green_gradient_top_bar"
>
<TextView
android:id="#+id/log_in_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/Einloggen_text"
style="#style/headerfromdialogs" />
<ImageView
android:id="#+id/log_in_header_exit_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/log_in_header_text"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:onClick="finish"
android:src="#drawable/x_android" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90" >
<TextView
android:id="#+id/log_in_benutzername_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="40dp"
android:layout_marginTop="80dp"
android:text="#string/Benutzername_text"
style="#style/dialogsGreenTexts" />
<EditText
android:id="#+id/log_in_benutzername_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/log_in_benutzername_text"
android:layout_alignBottom="#+id/log_in_benutzername_text"
android:layout_marginLeft="50dp"
android:layout_marginRight="20dp"
android:layout_toRightOf="#+id/log_in_benutzername_text"
android:ems="10"
android:hint="#string/hint_name_log_in"
>
</EditText>
<TextView
android:id="#+id/log_in_passwort_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/log_in_benutzername_text"
android:layout_below="#+id/log_in_benutzername_edit_text"
android:layout_marginTop="52dp"
android:text="#string/Passwort_text"
style="#style/dialogsGreenTexts" />
<EditText
android:id="#+id/log_in_passwort_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/log_in_passwort_text"
android:layout_alignBottom="#+id/log_in_passwort_text"
android:layout_alignLeft="#+id/log_in_benutzername_edit_text"
android:ems="10"
android:layout_marginRight="20dp"
android:inputType="textPassword"
android:hint="#string/hint_passwort_log_in"
>
</EditText>
<Button
android:id="#+id/log_in_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/log_in_passwort_edit_text"
android:layout_marginBottom="45dp"
android:layout_marginRight="-10dp"
android:onClick="logIn"
android:text="#string/Login_text"
style="#style/bold_text18" />
<!-- android:background="#drawable/green_gradient_button" -->
<TextView
android:id="#+id/log_in_passwort_vergessen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/log_in_button"
android:layout_alignLeft="#+id/log_in_passwort_edit_text"
android:text="#string/Passwort_vergessen_text"
style="#style/dialogsGreenTexts" />
<ProgressBar
android:id="#+id/waitProgessBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
/>
<TextView
android:id="#+id/userError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/log_in_benutzername_edit_text"
android:layout_alignLeft="#+id/log_in_benutzername_edit_text"
android:layout_marginBottom="5dp"
android:visibility="gone"
android:textColor="#color/errorRed"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
I want to scroll because on my se xperia neo V in horizontal orientation I can't see all view. Second problem is when I change orientation all view is broke. How change this view to show properly in both orientations?
but scroll doesn't work. Anyone know Why?
Please note :
1) Scroll view must have a single child (i.e all views must be included within a single root layout inside scroll view)
2) ScrollView works when your page size is greater the default height of the screen .
Please check both these things and if still does not work ... Paste some code to have a better understanding of the problem.
try this code
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="500dp"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#color/antiquewhiter"
android:weightSum="100"
>
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="10"
android:background="#drawable/green_gradient_top_bar"
>
<TextView
android:id="#+id/log_in_header_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="#string/Einloggen_text"
style="#style/headerfromdialogs" />
<ImageView
android:id="#+id/log_in_header_exit_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/log_in_header_text"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:onClick="finish"
android:src="#drawable/x_android" />
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="90" >
<TextView
android:id="#+id/log_in_benutzername_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="40dp"
android:layout_marginTop="80dp"
android:text="#string/Benutzername_text"
style="#style/dialogsGreenTexts" />
<EditText
android:id="#+id/log_in_benutzername_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/log_in_benutzername_text"
android:layout_alignBottom="#+id/log_in_benutzername_text"
android:layout_marginLeft="50dp"
android:layout_marginRight="20dp"
android:layout_toRightOf="#+id/log_in_benutzername_text"
android:ems="10"
android:hint="#string/hint_name_log_in"
>
</EditText>
<TextView
android:id="#+id/log_in_passwort_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/log_in_benutzername_text"
android:layout_below="#+id/log_in_benutzername_edit_text"
android:layout_marginTop="52dp"
android:text="#string/Passwort_text"
style="#style/dialogsGreenTexts" />
<EditText
android:id="#+id/log_in_passwort_edit_text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignBaseline="#+id/log_in_passwort_text"
android:layout_alignBottom="#+id/log_in_passwort_text"
android:layout_alignLeft="#+id/log_in_benutzername_edit_text"
android:ems="10"
android:layout_marginRight="20dp"
android:inputType="textPassword"
android:hint="#string/hint_passwort_log_in"
>
</EditText>
<Button
android:id="#+id/log_in_button"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignRight="#+id/log_in_passwort_edit_text"
android:layout_marginBottom="45dp"
android:layout_marginRight="-10dp"
android:onClick="logIn"
android:text="#string/Login_text"
style="#style/bold_text18" />
<!-- android:background="#drawable/green_gradient_button" -->
<TextView
android:id="#+id/log_in_passwort_vergessen_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/log_in_button"
android:layout_alignLeft="#+id/log_in_passwort_edit_text"
android:text="#string/Passwort_vergessen_text"
style="#style/dialogsGreenTexts" />
<ProgressBar
android:id="#+id/waitProgessBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:visibility="gone"
/>
<TextView
android:id="#+id/userError"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#+id/log_in_benutzername_edit_text"
android:layout_alignLeft="#+id/log_in_benutzername_edit_text"
android:layout_marginBottom="5dp"
android:visibility="gone"
android:textColor="#color/errorRed"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>