I m creating a settings page.In that I m having many fields,from them there is phone number field also,I want to wrap this edit text which is having phone number but it is not wrapping.I m having edit text with text they are wrapping but what is wrong in the number.
Here is my xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layoutsettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/Button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40sp"
android:layout_marginRight="40sp"
android:gravity="center_horizontal"
android:padding="10sp"
android:text="Signin with FB" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/UserFirstName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="FName"
android:textSize="15sp" />
<EditText
android:id="#+id/UserLastName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="LName"
android:textSize="15sp" />
</LinearLayout>
<EditText
android:id="#+id/PhoneNumber"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="PhoneNumber"
android:inputType="number"
android:textSize="15sp" />
<EditText
android:id="#+id/EmailAddress"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="EmailAddress"
android:textSize="15sp" />
<EditText
android:id="#+id/AddressLine1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Address Line 1"
android:textSize="15sp" />
<EditText
android:id="#+id/AddressLine2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:hint="Address Line 2"
android:textSize="15sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/Locality"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:hint="Locality"
android:textSize="15sp" />
<EditText
android:id="#+id/City"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:hint="City"
android:textSize="15sp" />
</LinearLayout>
<EditText
android:id="#+id/PinCode"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:hint="PinCode"
android:inputType="number"
android:textSize="15sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/Feedback"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.5"
android:text="Feedback"
android:textSize="15sp" />
<RatingBar
android:id="#+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:numStars="5"
android:rating="0.0"
android:stepSize="1.0" />
</LinearLayout>
</LinearLayout>
Please suggest me what to do to solve it.
Thanks.
change the match_parent to wrap_content
i think you can wrap it so by adding
android:phoneNumber="true"
in your XML layout. try this .
Try it:
<EditText
android:id="#+id/txtFamousRegion"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textMultiLine|number"
android:singleLine="false"
android:digits= "0123456789" />
Related
I've an application where i place Radio Button & TextView on a same line . But When i run on Nexus 7 it looks like this :
I want to create to 2nd one .How can i solve this :
Here is my XML :
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#drawable/loginsigninbackground" >
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >
<EditText
android:id="#+id/UserNameToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/username"
android:ems="10"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:paddingLeft="20dp"
>
<requestFocus />
</EditText>
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/password"
android:ems="10"
android:inputType="textPassword"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:layout_marginTop="5dp"
android:paddingLeft="20dp"
>
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/remember_me"
android:checked="false"
android:textSize="18sp"
android:textColor="#30D683"
android:button="#drawable/radio_selector"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/forgot_password"
android:textColor="#30D683"
android:textSize="18sp"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
/>
</LinearLayout>
<Button
android:id="#+id/ButtonNext"
android:layout_width="match_parent"
android:layout_height="60dp"
android:text="#string/next"
android:background="#drawable/customised_button_click"
android:onClick="gotosignup"
android:clickable="true"
android:textSize="20sp"
/>
<Button
android:id="#+id/ButtonSignUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#string/signup"
android:gravity="center"
android:textSize="20sp"
android:background="#drawable/customised_button_click"
android:onClick="gotosignup"
android:clickable="true"
/>
</LinearLayout>
</LinearLayout>
May I know what is the correct way to achieve my objective?Maybe this question too basic, but i did't find any suitable solution.Please Help me out.
Do not hardcode the height and width of your edit-text like you did
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="300dp"
android:layout_height="40dp"
android:hint="#string/password"
android:ems="10"
android:inputType="textPassword"
android:layout_gravity="center"
android:background="#drawable/customised_edit_text"
android:singleLine="true"
android:gravity="center|left"
android:textColorHint="#30D683"
android:layout_marginTop="5dp"
android:paddingLeft="20dp"
>
so basically it is
android:layout_width="300dp"
android:layout_height="40dp"
instead of give fill_parent or match_parent
android:layout_width="match_parent"
android:layout_height="match_parent"
or
android:layout_width="fill_parent"
android:layout_height="fill_parent"
do this for all text field and then try.
Try this..
There are two ways
1) Change EditText width as match_parent for both android:layout_width="match_parent"
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1" >
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >
<EditText
android:id="#+id/UserNameToLogin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:ems="10"
android:gravity="center|left"
android:hint="username"
android:paddingLeft="20dp"
android:singleLine="true"
android:textColorHint="#30D683" >
<requestFocus />
</EditText>
<EditText
android:id="#+id/UserPasswordToLogin"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_marginTop="5dp"
android:ems="10"
android:gravity="center|left"
android:hint="password"
android:inputType="textPassword"
android:paddingLeft="20dp"
android:singleLine="true"
android:textColorHint="#30D683" >
</EditText>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:checked="false"
android:text="remember_me"
android:textColor="#30D683"
android:textSize="18sp" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent"
android:cacheColorHint="#android:color/transparent"
android:text="forgot_password"
android:textColor="#30D683"
android:textSize="18sp" />
</LinearLayout>
<Button
android:id="#+id/ButtonNext"
android:layout_width="match_parent"
android:layout_height="60dp"
android:clickable="true"
android:onClick="gotosignup"
android:text="next"
android:textSize="20sp" />
<Button
android:id="#+id/ButtonSignUp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="true"
android:gravity="center"
android:onClick="gotosignup"
android:text="signup"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
and
2) change your LinearLayout width as 300dp and also remove android:layout_gravity="center" for both EditText
<LinearLayout
android:layout_width="300dp"
android:layout_height="wrap_content" >
<RadioButton
android:id="#+id/radioButtonRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/remember_me"
android:checked="false"
android:textSize="18sp"
android:textColor="#30D683"
android:button="#drawable/radio_selector"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/UserRememberMe"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="#string/forgot_password"
android:textColor="#30D683"
android:textSize="18sp"
android:cacheColorHint="#android:color/transparent"
android:background="#android:color/transparent"
/>
</LinearLayout>
change root linearlayout as
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >
and set layout width as 300dp in childlayout
<LinearLayout
android:layout_width="300dp"
android:layout_height="0dip"
android:layout_weight="1"
android:background="#android:color/white"
android:orientation="vertical" >
Hi
I am making a simple example in android but My problem is that
my textview and editfield is not align.It mean that
it should look like that
![Name editView
Rollnumber editView
Button on center][2]
It look like this
here is my code
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name"
/>
<EditText
android:id="#+id/entry"
android:hint="add name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Roll Number"
/>
<EditText
android:id="#+id/entry2"
android:hint="add roll number"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Click Me"
android:id="#+id/clickme"
/>
</LinearLayout>
Use TableLayout instead :
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:shrinkColumns="1"
android:stretchColumns="1" >
<TableRow
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Name :" />
<EditText
android:id="#+id/companyIdEditText_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:enabled="false"/>
</TableRow>
<TableRow
android:descendantFocusability="beforeDescendants"
android:focusable="true"
android:focusableInTouchMode="true" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="RollNumber :" />
<EditText
android:id="#+id/companyNameEditText_id"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="" />
</TableRow>
</TableLayout>
<Button
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:text="ClickMe"/>
</LinearLayout>
You can use the attribute weight. Set the the width of the row's chrildren to 0dp
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Roll Number"
/>
<EditText
android:id="#+id/entry2"
android:hint="add roll number"
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="2"
/>
</LinearLayout>
try this one...
<RelativeLayout 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:orientation="vertical" >
<TextView
android:id="#+id/text_view_boat1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="05dp"
android:text="Name" />
<EditText
android:id="#+id/entry"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBaseline="#id/text_view_boat1"
android:layout_marginRight="05dp"
android:layout_toRightOf="#id/text_view_boat1"
android:hint="add name" />
<LinearLayout
android:id="#+id/lin_lay"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/entry"
android:layout_marginTop="05dp"
android:orientation="horizontal" >
<TextView
android:id="#+id/text_view_boat2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Roll Number" />
<EditText
android:id="#+id/entry2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="add roll number" />
</LinearLayout>
<Button
android:id="#+id/clickme"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/lin_lay"
android:layout_marginTop="05dp"
android:text="Click Me" />
I am having a settings page in my application.In potrait all the fields are showing properly but when I switch to landscape mode the fields height are reducing and the hint of the fields are hiding which is not what I want.
I dont why it is happening.
It is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layoutsettings"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<Button
android:id="#+id/Button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="40sp"
android:layout_marginRight="40sp"
android:gravity="center_horizontal"
android:padding="10sp"
android:text="Signin with FB" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/UserFirstName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="FName"
android:textSize="15sp" />
<EditText
android:id="#+id/UserLastName"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="LName"
android:textSize="15sp" />
</LinearLayout>
<EditText
android:id="#+id/PhoneNumber"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="PhoneNumber"
android:inputType="number"
android:phoneNumber="true"
android:textSize="15sp" />
<EditText
android:id="#+id/EmailAddress"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="EmailAddress"
android:textSize="15sp" />
<EditText
android:id="#+id/AddressLine1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Address Line 1"
android:textSize="15sp" />
<EditText
android:id="#+id/AddressLine2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="Address Line 2"
android:textSize="15sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<EditText
android:id="#+id/Locality"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="Locality"
android:textSize="15sp" />
<EditText
android:id="#+id/City"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:hint="City"
android:textSize="15sp" />
</LinearLayout>
<EditText
android:id="#+id/PinCode"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:height="30dp"
android:layout_weight="0.5"
android:hint="PinCode"
android:inputType="number"
android:textSize="15sp" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/Feedback"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:text="Feedback"
android:textSize="17sp"
android:layout_marginLeft="20dp" />
<RatingBar
android:id="#+id/ratingbar"
style="#style/CustomRatingBar"
android:layout_width="wrap_content"
android:layout_height="50px"
android:layout_marginRight="20sp" />
</LinearLayout>
</LinearLayout>
If anybody can tell me what to do.
Thanks.
You need to create another folder in res called layout-land and add the same xml with the same code and arrange it accordingly. Then when you rotate your device/emulator then the xml in layout-land will inflate on your device/emulator
I have the following layout in my application
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TableRow>
<TextView
android:text="Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="#+id/username"
android:inputType="textEmailAddress"
/>
</TableRow>
<TableRow>
<TextView
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:id="#+id/password"
android:inputType="textPassword"
/>
</TableRow>
<!-- ADDED NEW -->
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/savePwd"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:text="Save Password (In encrypted clear text)"
/>
</LinearLayout>
</TableRow>
<TableRow
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<TextView
android:text="Please Log In"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/message_login"/>
</TableRow>
<TableRow android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:gravity="bottom|center">
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"/>
</TableRow>
</TableLayout>
The problem here is around the EditTexts. The TextViews expand to match the LinearLayout. This is not what I would like. I would like it to behave like the button below it (which doesn't expand the TextViews). Here is a screenshot...
Before...
After
Since you are using weights on the Edit Texts, remove the android:layout_width="wrap_content" from the Edit Texts, and the weight will be extended how you like.
This Rows for the TextViews/EditText should look like this instead....
<TableRow>
<TextView
android:text="Password"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.0"
android:id="#+id/password"
android:inputType="textPassword"
/>
</TableRow>
// 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="match_parent"
android:padding="5dp"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Username"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/username"
android:layout_marginLeft="5dp"
android:inputType="textEmailAddress"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Password"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<EditText
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/password"
android:layout_marginLeft="5dp"
android:inputType="textPassword"/>
</LinearLayout>
<!-- ADDED NEW -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/savePwd"/>
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:layout_marginLeft="5dp"
android:text="Save Password (In encrypted clear text)"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dp">
<TextView
android:text="Please Log In"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/message_login"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:gravity="bottom|center"
android:layout_marginTop="5dp"
android:layout_weight="1">
<Button
android:id="#+id/btn_login"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Log In"/>
</LinearLayout>
</LinearLayout>
I have been reading many posts here in stackoverflow about making a linear layout scroll and have applied all the specific advices to make it work but it still does not show on the left hand side. I am new to android and not sure what i am doing wrong.
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/scrollView1">
<LinearLayout
android:id="#+id/expense"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:gravity="start"
android:orientation="vertical"
tools:context=".Expense" >
<LinearLayout
android:id="#+id/tedsts"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/testffg"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".30"
android:text="Matter"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/tedssss"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".65"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<TextView
android:id="#+id/tetxttx"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginLeft="0dp"
android:layout_marginRight="10dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textColor="#color/gray_dark"
android:visibility="invisible" />
<EditText
android:id="#+id/teetttsss"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all"
android:ems="10"
android:gravity="top"
android:hint="dgdfgfgf"
android:inputType="textMultiLine" />
<LinearLayout
android:id="#+id/tesssstt"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:background="#drawable/rounded_all_clickable_selector"
android:clickable="true"
android:weightSum="1.0" >
<TextView
android:id="#+id/yttrree"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".20"
android:text="Date"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/rrrefffe"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight=".75"
android:ellipsize="end"
android:paddingLeft="10dp"
android:singleLine="true"
android:text=""
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:layout_width="15dp"
android:layout_height="wrap_content"
android:layout_weight="0.05"
android:src="#drawable/r_arrow" />
</LinearLayout>
<RadioButton
android:id="#+id/dfgrrrrr"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Cost"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gergrerrr"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded_all_clickable"
android:ems="10"
android:hint=""
android:inputType="numberDecimal"
android:singleLine="true" >
</EditText>
<RadioButton
android:id="#+id/rerreee"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginTop="5dp"
android:text="Time"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/gggrrrrre"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#drawable/roundede"
android:ems="10"
android:hint="grrrergg."
android:inputType="numberDecimal"
android:singleLine="true"
android:visibility="gone" >
</EditText>
<EditText
android:id="#+id/65gfhhggf"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="-4dp"
android:background="#drawable/rounded"
android:ems="10"
android:hint=""
android:inputType="numberDecimal" >
</EditText>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/gfhgfhtrhrth"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="50dp"
android:layout_marginTop="15dp"
android:visibility="gone" />
<TextView
android:id="#+id/ghjjhhhgh"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="30dp"
android:layout_marginTop="10dp"
android:layout_toRightOf="#+id/expense_TV_total"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<ImageButton
android:id="#+id/hgjhhghjhg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="#drawable/save_selector" />
</RelativeLayout>
</LinearLayout>
</ScrollView>
use this :
<?xml version="1.0" encoding="utf-8"?>
<ScrollView ...>
<LinearLayout ...>
...
...
</LinearLayout>
</ScrollView>
and set hieght to
android:layout_height="wrap_content"
as Karakuri said
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
//Your Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:weightSum="100">
// First Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing First Sub layout
// Second Sub Layout Under Main Layout
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_weight="10"
android:weightSum="100" >
<TextView
android:id="#+id/textView2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="TextView"
android:layout_weight="70" />
<EditText
android:id="#+id/editText2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="30" />
</LinearLayout>// Finishing Second Sub layout
similarly for 3rd,4rth,5th sub layouts and so on........
</LinearLayout> // Finishing Main Layout
</ScrollView> // Finishing ScrollView
Make the child of the ScrollView have android:layout_height="wrap_content" (currently yours has match_parent)
add
android:layout_width="match_parent"
android:layout_height="match_parent"
to your root ScrollView
I hope this code may be help you.
android:layout_width="match_parent"
android:layout_height="match_parent">