Layout TextView Hint not always showing - android

I have 4 textview, all numbers. The first one "#" is the hint and it shows up on my 4.2 and 2.2. The next three are "Hours, Minutes, Seconds" respectively and the hint shows up on 4.2 but not 2.2. Here is my xml for the them.
First Textview has # and the next three will say Hour, Minute, Second.
<ScrollView
android:id="#+id/mainBodyScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/calculateButton"
android:layout_alignParentLeft="true"
android:layout_below="#+id/perDistanceLayout"
android:fadeScrollbars="false"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:id="#+id/mainBodyLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_distance"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="#+id/distanceEntryLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp" >
<EditText
android:id="#+id/distanceText"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/default_number_hint"
android:inputType="number"
>
</EditText>
<Spinner
android:id="#+id/spinnerInput"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:entries="#array/spinner2_array" />
</LinearLayout>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_in"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/timeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<EditText
android:id="#+id/hourText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_hours"
android:inputType="number" />
<EditText
android:id="#+id/minuteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_minutes"
android:inputType="number" />
<EditText
android:id="#+id/secondText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_seconds"
android:inputType="number" />
</LinearLayout>
<Button
android:id="#+id/paceclearButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:minHeight="32dip"
android:text="#string/default_clear"
android:textSize="12dp" />
</LinearLayout>
</ScrollView>

Somehow setting center_horizontal value in the android:gravity is causing issues in Android 2.2 in displaying the hint.
Remove center_horizontal from the value of android:gravity to display the hint.

Related

EditText position within a Layout shifting

I have the following requirement:
i> Consider a layout tab_container of height 40 dp.
ii> The layout is divided into two equal individual parts in a
horizontal manner.
iii>Within each individual layout , there is a TextView and EditText
The issue , for example , I enter a value 3 on edit_text_1 and then tap on edit_text_2 and enter 222, both the layouts shifts a bit (right or left) .
This issue occurs when value is entered on edit_text_2 and edit_text_1 is tapped.
<LinearLayout
android:id="#+id/tab_container"
android:layout_width="fill_parent"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_marginTop="5dp"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:weightSum="2" >
<LinearLayout
android:id="#+id/linear_layout_1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="#+id/txt_view_1"
style="#style/button_text_style_white_hdpi"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.6"
android:gravity="center"
android:text="Sample"
android:textSize="14sp"
continental:typeface="roboto_bold" />
<EditText
android:id="#+id/edit_text_1"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.4"
android:background="#color/White"
android:gravity="center_vertical"
android:inputType="number"
android:maxLength="3"
android:textColor="#android:color/black"
android:textIsSelectable="false"
android:textSize="14sp" >
<requestFocus />
</EditText>
</LinearLayout>
<LinearLayout
android:id="#+id/linear_layout_2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal"
android:weightSum="1" >
<TextView
android:id="#+id/txt_view_2"
style="#style/button_text_style_white_hdpi"
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.6"
android:gravity="center"
android:text="Sample2"
android:textSize="14sp"
/>
<EditText
android:id="#+id/edit_text_2"
android:layout_width="0dp"
android:layout_height="30dp"
android:layout_marginLeft="5dp"
android:layout_weight="0.4"
android:background="#color/White"
android:gravity="center_vertical"
android:inputType="number"
android:maxLength="3"
android:textColor="#android:color/black"
android:textIsSelectable="false"
android:textSize="14sp" >
<requestFocus />
</EditText>
</LinearLayout>
</LinearLayout>
Any suggestions will be helpful.

Words get cut of in Android ListView

I'm stuck with a small problem in my listview. I tried several things like adding padding or changing the margins. But this didn't fix my problem.
Words keep getting cut of in the last rule.
<?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="match_parent"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/violationstitlebar"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolPos"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolDescriptionNLB"/>
<TextView
android:layout_width="#dimen/violation_list_col3"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskDescriptionFRB" />
<TextView
android:layout_width="#dimen/violation_list_col5"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolBLS"/>
<TextView
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolRepeat"
/>
<TextView
android:layout_width="#dimen/violation_list_col8"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListPosition"
android:paddingLeft="10dp"
android:paddingBottom="10dp"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescription"
android:layout_weight="1"
android:maxLines="4"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col3"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDesc"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescriptionFRB"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col5"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDescFRB"
/>
<Spinner
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:id="#+id/spViolListConclusion"
style="?android:dropDownSpinnerStyle"/>
<EditText
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/etViolListCounter"
android:inputType="number"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col8"
android:layout_height="50dp"
android:id="#+id/ibViolListDelete"
/>
</LinearLayout>
</LinearLayout>
Does anyone have an idea how to fix this?
kind regards,
Tim
give some limitaion to charaters ,while adding the content of your NLB
maxlines, minimum lines
<EditText
android:id="#+id/AddressEdittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="15dp"
android:background="#drawable/retangle_shape"
android:gravity="top|left"
android:hint="Type Here..."
android:inputType="textMultiLine"
android:lines="5"
android:maxLines="10"
android:minLines="5"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/padding"
android:paddingRight="#dimen/padding"
android:paddingTop="5dp"
android:scrollbars="vertical" >
</EditText>
Try using this property also with some padding bottom:
android:includeFontPadding="false"
And:
android:baselineAligned="false"
I think you can solve it with layout_weight attribute.
More info on layout_weight can be found on:
http://ugia.io/2012/01/19/android-linearlayout-distribution-explained-weight-and-sizes/
http://developer.android.com/guide/topics/ui/layout/linear.html

EditText disappeared after being placed in a linear layout

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

moving button bar

I have an activity that allows me to enter content. It consists of edit text and button bar. Whenever I what to input something to the edit text, a keyboard pops up and the button bar is on top if it so I can't see what I'm typing if the content is long(it goes behind the button bar). How can i fix it ?
my code is:
<RelativeLayout
android:id="#+id/toplayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:background="#drawable/notetop"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingTop="5dp" >
<TextView
android:id="#+id/title_text1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/title"
android:textColor="#000000"
android:textStyle="bold"
android:textSize="18sp" />
<EditText
android:id="#+id/etTitleJoke"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_toRightOf="#+id/title_text1"
android:background="#android:color/transparent"
android:hint="#string/no_title"
android:imeOptions="actionNext"
android:singleLine="true"
android:textColor="#000000"
android:textSize="18sp" >
</EditText>
</RelativeLayout>
<view
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/etContentJoke"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="#+id/toplayout"
class="ie.myjokes.LineEditText"
android:background="#android:color/transparent"
android:capitalize="sentences"
android:scrollHorizontally="true"
android:fadingEdge="vertical"
android:gravity="top"
android:padding="5dp"
android:scrollbars="vertical"
android:textColor="#000000"
android:textSize="22sp" >
<requestFocus />
</view>
<LinearLayout
android:id="#+id/footer"
style="#android:style/ButtonBar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="#+id/btnSave"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickSave"
android:text="#string/btn_save"
android:textColor="#000000" />
<Button
android:id="#+id/btnCancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:onClick="onClickCancel"
android:text="#string/btn_cancel"
android:textColor="#000000" />
</LinearLayout>
nevermind, I added this line into my activity and its gone now. Thank you
android:windowSoftInputMode="adjustPan"

auto grow edittext below buttons above keybord

Yet another same problem for android which drive developers crazy!
I want to make buttons above keyboard...
Here is my xml:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/home"
android:layout_width="910dp"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:keepScreenOn="true"
android:orientation="vertical"
android:padding="15dip" >
<com.custom.webview
android:id="#+id/webView1"
android:layout_width="900dp"
android:layout_height="350dp"
android:visibility="gone" >
</com.custom.webview>
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:paddingBottom="5dip"
android:paddingTop="20dip"
android:text="#string/choose_the_outcome"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<Spinner
android:id="#+id/spinner1"
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1"
android:entries="#array/call_outcomes" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-light"
android:paddingBottom="5dip"
android:paddingTop="20dip"
android:text="#string/notes"
android:textAllCaps="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="25sp" />
<EditText
android:id="#+id/editText1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:fontFamily="sans-serif-light"
android:inputType="textMultiLine" >
</EditText>
<LinearLayout
style="?android:attr/buttonBarStyle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="25dip" >
<Button
android:id="#+id/button1"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:onClick="onCancel"
android:text="#android:string/cancel" />
<Button
android:id="#+id/button2"
style="?android:attr/buttonBarButtonStyle"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.5"
android:onClick="onSave"
android:text="#string/save" />
</LinearLayout>
</LinearLayout>
just move all your layoouts as they are in the RelativeLayout. It might fix an issue.
Add this line
android:windowSoftInputMode="adjustResize|stateHidden"
to AndroidManifest.xml <activity> tag
You need to to do the following:
Just Make the text view child of a spinner
or put text view height = wrap_content.

Categories

Resources