i need your help. Basically I created a scrollView as a parent layout of an activity . Now i need to add many widgets inside the activity including an edittext containing large text values set inside this edittext which is also scrollable , but my text inside an edit text not scrolling smoothly? i need text area like widgets , my xml code shown below
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#498BF4">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Registration"
android:gravity="center_horizontal"
android:textSize="20dip"/>
</LinearLayout>
<ScrollView
android:id="#+id/scroll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="User_id:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/user">
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="FirstName:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/fname">
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="LastName:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/lname">
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Email:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/email">
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Currency:*"
android:textSize="15dip"/>
<Spinner
android:id="#+id/spinner1"
android:layout_width="fill_parent"
android:layout_height="40dip">
</Spinner>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Date of Birth:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/dob">
</EditText>
<LinearLayout
android:id="#+id/agepermission"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:visibility="gone">
<EditText
android:layout_width="fill_parent"
android:layout_height="150dip"
android:id="#+id/ageterms"
android:maxLines="10"
android:textSize="10dip"
android:text="#string/hello"
>
</EditText>
<CheckBox
android:text="I have permission to use the website from parent/guardian.*"
android:id="#+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</CheckBox>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Parent Name:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/pname">
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Parent Email:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="40dip"
android:id="#+id/pemail">
</EditText>
</LinearLayout>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Terms and conditions:*"
android:textSize="15dip"/>
<EditText
android:layout_width="fill_parent"
android:layout_height="200dip"
android:id="#+id/terms"
![android:text="i need your help. Basically I created a scrollView as a parent layout of an activity . Now i need to add many widgets inside the activity including an edittext containing large text values set inside this edittext which is also scrollable , but my text inside an edit text not scrolling smoothly? i need text area like widgets i need your help. Basically I created a scrollView as a parent layout of an activity . Now i need to add many widgets inside the activity including an edittext containing large text values set inside this edittext which is also scrollable , but my text inside an edit text not scrolling smoothly? i need text area like widgets i need your help. Basically I created a scrollView as a parent layout of an activity . Now i need to add many widgets inside the activity including an edittext containing large text values set inside this edittext which is also scrollable , but my text inside an edit text not scrolling smoothly? i need text area like widgets i need your help. Basically I created a scrollView as a parent layout of an activity . Now i need to add many widgets inside the activity including an edittext containing large text values set inside this edittext which is also scrollable , but my text inside an edit text not scrolling smoothly? i need text area like widgets"][2]
android:inputType="textMultiLine"
android:textSize="10dip"
>
</EditText>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="By clicking on 'Sign Up' button below you are agreeing to the Terms of Service above and both the Program Policy and the Privacy Policy."
android:textSize="15dip"/>
<Button
android:text="Sign Up"
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="40dip"
>
</Button>
</LinearLayout>
</ScrollView>
</LinearLayout>
use below tag in your edittext , if it input is multiline
android:inputType="textMultiLine"
I am having the same problem here.
So far I know the only solution is to disable the scrolling of the ScrollView when the EditText got focus.
Related
The layout definition is below. Basically I want the two buttons to be the same width, but right now their width is determined by the string they display, is there a better way to lay this out such that the buttons are the same width and that the Button+EditText combo fills the width of the screen?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/editorlinearlayout"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center">
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/setNameBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Set Item Name "/>
<EditText android:id="#+id/nameTxtBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
<LinearLayout android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/setGroupBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Group Name"/>
<EditText android:id="#+id/groupTxtBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
Edit:
I've tried using a TableLayout as was suggested below, but now the EditText's don't fill the remaining portion of the screen. See the image and layout below.
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TableRow>
<Button android:id="#+id/setNameBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Set Item Name "/>
<EditText android:id="#+id/nameTxtBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow>
<Button android:id="#+id/setGroupBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Set Group Name"/>
<EditText android:id="#+id/groupTxtBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
the trick is to combine the tableview defined in the edit above with a strechColumn tag:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">
<TableRow>
<Button android:id="#+id/setNameBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=" Set Item Name "/>
<EditText android:id="#+id/nameTxtBox"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
Use a TableLayout and TableRows.
Three options:
Put this in a TableLayout instead of the nested LinearLayout thing you are currently doing
Change your nesting from a vertical parent with horizontal children to a horizontal parent with vertical children (however, this opens up possible vertical positioning issues, so I don't favor this option)
Use a RelativeLayout and all of the layout_* attributes that RelativeLayout children have available to them
I'd favor option 1, personally.
you can use specific width and height for laout_width/layout_height, as in layout_width="150dip". You run the risk of having a button that can't fit all your text though, but if your text is fixed, you can double check to make sure it's all good.
I am finishing implementing an application, which has inside activity for sending a message (just editText and two buttons - send and cancel, message is then send to the fixed address). When i start this activity, on a screen I see textBox and keyboard, which is immediately shown. But disadvantage of this is that theese buttons are covered or half-covered by the keyboard and all I want is to have is similar as in the messages. When keyboard is visible, shrink the text field and show in addtion buttons above the keyboard, if I hit back arrow on under the screen, keyboard dissapears, nearly whole screen would be taken by this editText and on the bottom there will be those two buttons... can it be real?
Edit: How to make it happen, that this screen will have with active keyboard visible all buttons?
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:layout_height="fill_parent"
android:background="#drawable/poz3"
android:padding="10dip">
<TextView
android:text="Message:"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="25dip"
android:textColor="#color/black"
/>
<EditText
android:id="#+id/message"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Write message here"
android:gravity="top"
android:lines="7"
android:inputType="textShortMessage|textAutoCorrect|textCapSentences|textMultiLine"
android:imeOptions="actionSend|flagNoEnterAction"
/>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="horizontal"
android:layout_height="fill_parent"
>
<Button
android:id="#+id/enquirySendButton"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:text="Send"
android:layout_weight="1.0"
android:background="#drawable/custom_button"
/>
<Button
android:id="#+id/enquiryExitButton"
android:layout_width="fill_parent"
android:layout_height="60dip"
android:text="Cancel"
android:layout_weight="1.0"
android:background="#drawable/custom_button"
/>
</LinearLayout>
</LinearLayout>
have got it working.
In your XML layout, in the main layout (RelativeLayout) have a LinearLayout with the buttons and android:layout_alignParentBottom="true". Add your other layout below, with clause android:layout_above="#id/yourButtonLayout"
My real life code goes like this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textSize="14dip"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/taskEditFormBottomButtons"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:baselineAligned="true"
android:orientation="horizontal"
android:layout_alignParentBottom="true"
>
<Button
android:id="#+id/taskEditFormBTSave"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/save"
android:layout_weight="0.5"
/>
<Button
android:id="#+id/taskEditFormBTCancel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textStyle="bold"
android:text="#string/cancel"
android:layout_weight="0.5"
/>
</LinearLayout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_above="#id/taskEditFormBottomButtons"
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
....
>
....
</RelativeLayout>
</ScrollView>
</RelativeLayout>
This might be of some help,if not already tried..
http://developer.android.com/resources/articles/on-screen-inputs.html
I am facing trouble to set WrapText kind of facility in EditText.
Problem: When i try tp enter data in EditText, it goes beyond the screen width (scrolling horizontally). Instead of it should be appear in next-line.
Want to perform: Actually, i want to implement multiline edittext, initially it should display with single-line as usual, but it will be expanded vertically(not horizontally) as when data is being entered.
Please suggest me what should i do ??
Please have a look at below image:
I have done the below XML coding:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:stretchColumns="1">
<TableRow android:id="#+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView
android:text="Name:"
android:id="#+id/TextView01"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:textSize="16dip">
</TextView>
<EditText
android:id="#+id/txtViewName"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:inputType="textFilter|textMultiLine|textNoSuggestions"
android:scrollHorizontally="false">
</EditText>
</TableRow>
</TableLayout>
You can try to change the width to fill_parent.
try adding following code in your edit text if you want to wrap it in a single line:
android:singleLine="true"
OR set the width of your edittext to fill_parent or any value in dip if you want multiline.
I just change this: android:layout_width ="0dip" and it is working fine.
Multiline edittext but initially it is being displayed one line, it will be expanded vertically(not horizontally) as and when the more and more data are being entered.
Just use both android:stretchColumns="1" and android:shrinkColumns="1" instead the only one android:stretchColumns="1":
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:stretchColumns="1"
android:shrinkColumns="1">
I've tested it on a 2.1 emulator enclosing the code (with fill_parent in the edit text) inside this relative layout and appears to be ok.
<?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="fill_parent">
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="10dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:stretchColumns="1">
<TableRow android:id="#+id/TableRow02" android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView
android:text="Name:"
android:id="#+id/TextView01"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:textSize="16dip">
</TextView>
<EditText
android:id="#+id/txtViewName"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:inputType="textFilter"
android:scrollHorizontally="false">
</EditText>
</TableRow>
</TableLayout>
</RelativeLayout>
Maybe you can navigate the xml tree in the eclipse outline window and see what view is bigger than the screen.
I want the EditText to fill all the available space to the right side until the button placed on the right of it. I'm using RelativeLayout to construct such a view. But in result I don't have my button visible, the only EditText. Please advice how to make both of them visible.
<?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">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp">
<EditText
android:id="#+id/edit_text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Task description">
</EditText>
<Button
android:id="#+id/ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:layout_toRightOf="#id/edit_text">
</Button>
</RelativeLayout>
</LinearLayout>
You're putting your button first. You have to place the item you want fixed before the others.
<Button
android:id="#+id/ok_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="OK"
android:layout_alignParentRight="true"
/>
<EditText
android:id="#+id/edit_text"
android:layout="align_parent_left"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_toLeftOf="#id/ok_button"
android:hint="Task description"
/>
The way you have it, your edittext knows nothing about the button that follows it, so why should it not take up the entire width of the parent just like you told it to?
I have the following code in my layout.xml.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_height="wrap_content" android:layout_width="fill_parent">
<EditText android:hint="#string/feed_url"
android:id="#+id/feedUrl" android:textSize="14dp" android:inputType="textUri"
android:layout_marginRight="45dp" android:layout_height="wrap_content" android:layout_width="fill_parent">
</EditText>
<Button android:id="#+id/getGraph"
android:text="#string/get"
android:layout_toRightOf="#id/feedUrl"
android:layout_alignParentRight="true"
android:layout_height="wrap_content" android:width="45dp" android:layout_width="wrap_content">
</Button>
</RelativeLayout>
<WebView android:id="#+id/wv1" android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout>
In the eclipse Plugin layout creator, the EditText and button are shown properly. (see the below screenshot)
But on the device and emulator, the button is not hidden. (see the below screenshot)
Any idea why the button is getting hidden in the device?
Try the following changes to your code. You have to define the button first, since it is of fixed width, and then place the EditText to fill the rest of the space, placed to the left of the button. The button also has to be defined first (prior to Android 2.2, that is).
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
<Button
android:id="#+id/getGraph"
android:text="#string/get"
android:layout_alignParentRight="true"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
/>
<EditText
android:hint="#string/feed_url"
android:id="#+id/feedUrl"
android:textSize="14dp"
android:inputType="textUri"
android:layout_marginRight="45dp"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:layout_toLeftOf="#id/getGraph"
/>
</RelativeLayout>
I cannot see the button in the layout builder... the reason, I think is that the EditText width is fill parent so it fills parent pushing the button out. If you must use RelativeLayout, you need to define width of the EditText explicitly. Otherwise you may want to switch to horizontal LinearLayout and set weight of the edit box to "1".
Also, there are invalid options for RelativeLayout:
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal
You can also use LinearLayout instead of RelativeLayout to archive this. You can use android:layout_weight to make Button not be overlaid by EditText. Following is the sample xml that may work:
<LinearLayout android:orientation="horizontal"
android:layout_height="wrap_content" android:layout_width="fill_parent">
<EditText android:hint="#string/feed_url"
android:id="#+id/feedUrl" android:textSize="14dp"
android:inputType="textUri" android:layout_marginRight="45dp"
android:layout_height="wrap_content" android:layout_width="fill_parent" />
<Button android:id="#+id/getGraph" android:text="#string/get"
android:layout_height="wrap_content" android:width="45dp"
android:layout_width="wrap_content"
android:layout_weight="1" />
</LinearLayout>