I am facing some problems while developing a screen involving a tabWidget. I have used a scrollView. The problem is that when i scroll up, the editText overlaps the tabs. Here is my main.xml file. So when i try scrolling up, the title editText begins to overlap on the TabHeading.
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:id="#+id/tabHost"
>
<TabWidget android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#android:id/tabs"
/>
<FrameLayout android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="50px"
android:id="#android:id/tabcontent"
>
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/scrollview">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/createAlarmTab"
android:paddingTop="50px"
>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/title"
android:visibility="visible"
/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/desciption"
android:visibility="visible"
android:singleLine="false"
android:lines="4"
android:gravity="top"
android:padding="10px"
/>
<DatePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/alarmDate"
android:visibility="visible"
android:padding="10px"
/>
<TimePicker
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/alarmTime"
android:visibility="visible"
android:padding="10px"
/>
</LinearLayout>
</ScrollView>
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content"
android:id="#+id/viewAlarmTab"
android:paddingTop="50px"
>
<ListView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/alarmList"
android:visibility="visible"
android:padding="10px"
/>
</LinearLayout>
</FrameLayout>
</TabHost>
Managed to solve it. Enclosed the scrollview inside a linearLayout and added some padding.
Related
I have Activity with the ScrollView and the Button in the footer. If I click on EditText for input text, the keyboard lifts up the Views. And the Button and the ScrollView shift above of the keyboard. I need to the keyboard not to lift the Views, but should cover on top the Views.
How can I do this?
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
android:id="#+id/primaryLayout"
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:fitsSystemWindows="true"
tools:context="com.test.test.TestActivity">
<LinearLayout
tools:context="com.test.myapplication.MainMenuActivity"
android:background="#color/colorLightGreySubHeaderBg"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<include layout="#layout/content_header"/>
<include layout="#layout/content_subheader"/>
<ScrollView
android:id="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorMainWhite"
android:layout_weight="1"
android:orientation="vertical">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:background="#color/colorMainWhite"
style="#style/nls_1">
<TextView
android:id="#+id/tvNL1"
tools:text="#string/tools_txt_nl1"
style="#style/tvs_lo_text_32_bold_ellipsized" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="#dimen/size_20px"
android:paddingBottom="#dimen/size_20px"
android:paddingLeft="#dimen/paddingLayoutDefaultNormal"
android:paddingRight="#dimen/paddingLayoutDefaultNormal"
android:background="#color/colorLightGreySubHeaderBg"
android:orientation="vertical">
<TextView
android:id="#+id/testName"
android:text=""
tools:text="#string/tools_txt_test"
style="#style/tvs_lo_text_26_bold" />
<TextView
android:id="#+id/testType"
style="#style/tvs_lo_text_26"
tools:text="#string/tools_txt_test2"/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#color/colorMainWhite">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:paddingTop="#dimen/size_35px"
android:paddingLeft="#dimen/paddingLayoutDefaultNormal"
android:paddingRight="#dimen/paddingLayoutDefaultNormal">
<TextView
style="#style/tvs_lo_text_26"
android:paddingBottom="#dimen/size_35px"
android:text="#string/txt_enter"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/size_30px"
android:orientation="horizontal">
<ImageView
android:id="#+id/icontest"
android:layout_alignParentLeft="true"
android:layout_width="#dimen/size_45px"
android:layout_height="#dimen/size_45px"
android:src="#drawable/icon_test"/>
<EditText
android:id="#+id/editTextTest"
android:layout_toRightOf="#+id/iconTestId"
android:layout_toLeftOf="#+id/testAbbreviation"
android:paddingLeft="#dimen/size_20px"
android:inputType="numberDecimal"
android:hint="#string/txt_test"
android:textColorHint="#color/colorTxtMainBlue"
android:background="#color/colorMainWhite"
style="#style/ets_lo_text_32_blue"/>
<TextView
android:id="#+id/testAbbreviation"
android:layout_alignParentRight="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="#style/tvs_lo_text_32_blue"
tools:text="test"/>
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorMainBlue"/>
<TextView
style="#style/tvs_lo_text_26"
android:paddingTop="#dimen/size_35px"
android:paddingBottom="#dimen/size_35px"
android:text="#string/txt_test"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/size_30px">
<ImageView
android:id="#+id/iconDescriptionId"
android:layout_alignParentLeft="true"
android:layout_width="#dimen/size_45px"
android:layout_height="#dimen/size_45px"
android:src="#drawable/icon_test"/>
<EditText
android:layout_toRightOf="#+id/iconDescriptionId"
android:paddingLeft="#dimen/size_20px"
android:inputType="textMultiLine"
android:minLines="1"
android:id="#+id/editTextTest"
android:hint="#string/txt_test"
style="#style/ets_lo_text_32_blue"
android:textColorHint="#color/colorTxtMainBlue"
android:background="#color/colorMainWhite"
android:singleLine="true"
android:maxLines="1" />
</RelativeLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="2dp"
android:background="#color/colorMainBlue"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorMainWhite"
android:orientation="horizontal">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="#dimen/paddingLayoutDefaultNormal"
android:paddingLeft="#dimen/paddingLayoutDefaultNormal"
android:paddingRight="#dimen/paddingLayoutDefaultNormal"
android:paddingTop="#dimen/paddingLayoutDefaultNormal"
android:gravity="bottom">
<include layout="#layout/layout_blue_button" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
Try using this in your activity:
getActivity().getWindow().setSoftInputMode(
WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
or in your Manifest:
<activity
...
android:windowSoftInputMode="adjustPan">
</activity>
I want to apply background image on Relativelayout Under ScrollView.
The Image Appear on XML View but Not Appear on Actual device.
I have added ImageView on Ralativelayout
>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="#+id/parentView"
>
<ImageView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="#drawable/cloudbg"
/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="#+id/vo"
android:layout_below="#id/relativeLayout"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="XYZ"
/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="25dp"
android:layout_height="wrap_content"
android:id="#+id/textvo"
android:text="Voter Number"
/>
</LinearLayout>
</RelativeLayout>
</ScrollView>
Thanks
can try this way:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/cloudbg">
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:id="#+id/vo"
android:layout_below="#id/relativeLayout"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_height="wrap_content">
<TextView
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="XYZ"
/>
<TextView
android:layout_width="wrap_content"
android:layout_marginLeft="25dp"
android:layout_height="wrap_content"
android:id="#+id/textvo"
android:text="Voter Number"
/>
</LinearLayout>
</ScrollView>
Use android:background="#drawable/background_image" attribute in Relative or Linear Layout tag.
Set background for scrollview
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/ic_launcher" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
</LinearLayout>
</ScrollView>
I know that similar questions have been asked before , but I'm unable to figure out what to do with my layout.
The problem:
The keyboard overlaps the AutoCompleteTextView when many lines are added to it. I have tried wrapping everything in a scrollview and so on but that didn't help.
Any help would be appreciated.
Thanks in advance
<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<HorizontalScrollView
android:id="#+id/tabsScroll"
android:layout_width="fill_parent"
android:fadingEdge="horizontal"
android:fillViewport="true"
android:layout_height="wrap_content"
android:scrollbars="#null">
<TabWidget
android:id="#android:id/tabs"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0" />
</HorizontalScrollView>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="0" />
<android.support.v4.view.ViewPager
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<ScrollView
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/scrollView1">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/InputOuterContainer"
android:layout_alignParentBottom="true">
<View
android:background="#ffcccccc"
android:layout_width="fill_parent"
android:layout_height="1.0px" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:background="#FFFFFF"
android:layout_height="wrap_content"
android:id="#+id/InputContainer">
<AutoCompleteTextView
android:id="#+id/InputTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:hint="#string/Ready"
android:layout_weight="1.0"
android:imeOptions="actionGo"
android:inputType="textNoSuggestions"
android:selectAllOnFocus="true"
android:focusable="true" />
<ImageButton
android:id="#+id/ButtonRun"
android:paddingLeft="16.0dip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/go"
android:scaleType="center"
style="?android:attr/borderlessButtonStyle"
android:layout_gravity="top" />
</LinearLayout>
</LinearLayout>
</ScrollView>
</LinearLayout>
</TabHost>
Ok, in your manifest, add android:windowSoftInputMode to your activity,
check this : http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft
then set android:windowSoftInputMode to adjustPan or adjustResize
I added this line in the ScrollView tag:
android:isScrollContainer="false"
I want to place a TextView below the red zone in the following image but I just can do it.
Until now I have the following layout:
<TabHost android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/tabhost1"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TabWidget
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#android:id/tabs"
android:layout_alignParentBottom="true"
/>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#android:id/tabcontent"
>
</FrameLayout>
</RelativeLayout>
</TabHost>
<LinearLayout android:layout_width="fill_parent"
android:layout_below="#id/layout"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="0 restaurant trouves"
android:gravity="center_horizontal"
android:layout_alignParentBottom="true"
android:textSize="15dip"
android:textColor="#000000"
/>
</LinearLayout>
Can someone tell what is the right code for placing the textView below the red tab?
Thank you!
Is everything you mentioned in your post in one XML file? It looks like its not well formatted and your screenshot does not make it clear too, but I am giving it a try.
It seems that your TextView is not even inside the RelativeLayout.You are closing it's tag before declaring your TextView, so you have to move it into RelativeLayout.
And I don't know if you want to show this TextView in every single Tab. But if it is like that, you could try the following scheme:
<?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:orientation="vertical" >
<TabHost
android:id="#android:id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="TextView" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/textView1"
android:text="TextView" />
</RelativeLayout>
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="#+id/tab1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="#+id/tab2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
<LinearLayout
android:id="#+id/tab3"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
There are two TextViews in this example. One is centered and the other one is drawn below of the first with: android:layout_below="#id/textView1".
Now you have to do this with your Views...
your layout code doesn't seem to have everything you have on the screenshot, so I'm not sure how your red set of tabs work but here's a mockup with a simple view:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TabWidget
android:id="#android:id/tabs"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true" />
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="#android:id/tabs"
android:layout_centerHorizontal="true"
android:background="#FFFFFF"
android:gravity="center_horizontal"
android:text="0 restaurant trouves"
android:textColor="#000000"
android:textSize="15dip" />
<View
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_above="#+id/text"
android:background="#ff0000" />
<FrameLayout
android:id="#android:id/tabcontent"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
</FrameLayout>
</RelativeLayout>
That will give you this: (eclipse screenshot, no tabs in widget)
How do I let my include exactly at the end of the screen? At the time he gets to the end of the content.
<!-- language: lang-xml -->
<?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">
<ScrollView android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#f6ba79"
android:orientation="vertical" android:id="#+id/layout">
<LinearLayout android:id="#+id/linearLayout2"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#drawable/preferences_background">
<include android:id="#+id/include1" android:layout_width="fill_parent"
layout="#layout/top" android:layout_height="wrap_content"></include>
<LinearLayout android:layout_width="fill_parent"
android:gravity="center" android:id="#+id/linearLayout1"
android:layout_height="wrap_content">
<LinearLayout android:orientation="vertical"
android:layout_width="270dp" android:id="#+id/body"
android:layout_height="wrap_content" android:focusableInTouchMode="true">
<ImageView android:src="#drawable/preferences"
style="#style/Theme.Connector.ImageElement" android:layout_width="wrap_content"
android:id="#+id/title" android:layout_height="wrap_content"></ImageView>
<Spinner android:layout_width="fill_parent"
style="#style/Theme.Connector.WelcomeSpinner"
android:layout_weight="1" android:id="#+id/spinner_isp"
android:layout_height="wrap_content" />
<EditText android:singleLine="true" android:hint="#string/txt_user"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:id="#+id/edit_user" style="#style/Theme.Connector.PreferencesInput" />
<EditText android:singleLine="true" android:hint="#string/txt_password"
android:layout_height="wrap_content" android:layout_width="fill_parent"
android:id="#+id/edit_password" android:password="true"
style="#style/Theme.Connector.PreferencesInput" />
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent" android:id="#+id/frm_action"
android:layout_height="fill_parent" android:baselineAligned="false">
<Button android:text="#string/btn_save"
android:layout_weight="0" android:layout_width="130dp"
android:layout_height="wrap_content" style="#style/Theme.Connector.Button"
android:layout_gravity="center" android:id="#+id/btn_save"></Button>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</ScrollView>
<include android:id="#+id/include1" android:layout_width="fill_parent"
layout="#layout/menu" android:layout_height="wrap_content" android:layout_alignParentBottom="true"></include>
</RelativeLayout>
The problem is that your ScrollerView has a layout_height="fill_parent". RelativeLayout will make that view fill the entire space.
A LinearLayout will work better in your case:
<?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">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:background="#f6ba79"
android:orientation="vertical"
android:id="#+id/layout">
...
</ScrollView>
<include
android:id="#+id/include1"
android:layout_width="fill_parent"
layout="#layout/menu"
android:layout_height="wrap_content" />
</LinearLayout>
The key here is to have the height of the ScrollerView set to 0dp and the weight set to 1 (or any number really). LinearLayout will then stretch the ScrollerView to fill the view and still make room for the #layout/menu at the bottom.