I'm having an awkward error, and do not have any clue about what's the cause.
I'm working on a maintenance of an android map application, it was using GoogleMap API, but now I've changed it to MapLink API. One of the view is this one:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="1">
<EditText
android:id="#+id/searchText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="3dip"
android:ems="10"
android:hint="Busca"
android:maxLines="1"
android:layout_weight="0.85" />
<Button
android:id="#+id/searchBtn"
android:layout_width="32dp"
android:layout_height="32dp"
android:background="#drawable/magnifier13"
android:onClick="search" />
</LinearLayout>
<View
android:id="#+id/separator1"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#color/red" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<br.com.maplink.map.MapTemplate
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent">
</br.com.maplink.map.MapTemplate>
<ImageView
android:id="#+id/drag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/androidpin64"
android:visibility="gone" />
</RelativeLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="100dip"
android:orientation="vertical" >
<View
android:id="#+id/separator2"
android:layout_width="fill_parent"
android:layout_height="2dip"
android:background="#color/red" />
<EditText
android:id="#+id/txtEtiqueta"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:layout_marginTop="3dip"
android:ems="10"
android:hint="Etiqueta"
android:maxLines="1" >
<requestFocus />
</EditText>
<Button
android:onClick="create"
android:id="#+id/btnCadastrarPOI"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"
android:layout_marginRight="10dip"
android:paddingRight="10dip"
android:text="ConcluĂdo" />
</LinearLayout>
When I click on the top textbox the keyboard just appear and when it's dismissed everything is normal, but when I click on the bottom textbox, the keyboard scroll the content page up and the content above the map goes off the view, when the keyboard is dismissed the content page scrolls back to it's original, but the content above the map is covered by a black frame, if I rotate the device or try to click on the top text box the black frame disappear.
I've already tried to recreate the view on other file but it keep this problem, I've tried the same thing on other project and everything is working fine.
Also, this problem only happen on landscape orientation;
Thanks.
Related
When the keypad appears when the user clicks on an EditText, parts of the layout is covered by the keypad. So I tried using ScrollView so the user can scroll down and see the rest of the layout. But its not scrolling. I can't seem to get my scroll view working. The I have searched on stackoverflow for the solution for 3 hours and couldn't find it.
<?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"
android:fillViewport="true">
<RelativeLayout
android:id="#+id/new_meal_form_relative"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/meal_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="2dp"
android:text="#string/meal_label"
android:textSize="20sp"
android:textIsSelectable="false"
android:textStyle="bold"/>
<EditText
android:id="#+id/meal_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_label"
android:hint="Event Title"
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="#+id/meal_location"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_name"
android:hint="Location(eg: CSC Room232)* "
android:inputType="textCapSentences"
android:maxLines="1"/>
<EditText
android:id="#+id/meal_event"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#id/meal_location"
android:gravity="top"
android:hint="Description of the event. What kind of food. Any additional info... \n"
android:inputType="textMultiLine|textCapSentences"/>
<TextView
android:id="#+id/textViewRating"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/meal_event"
android:text="Rating: "/>
<Spinner
android:id="#+id/rating_spinner"
android:layout_width="71dp"
android:layout_height="47dp"
android:layout_alignTop="#+id/textViewRequired"
android:layout_toRightOf="#+id/textViewRating"/>
<TextView
android:id="#+id/textViewRequired"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="#+id/textViewRating"
android:layout_alignParentRight="true"
android:layout_gravity="right"
android:text="*Required"
android:textColor="#ffff4b48"
android:textSize="15sp"/>
<com.parse.ParseImageView
android:id="#+id/meal_preview_image"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_below="#+id/rating_spinner"
android:layout_centerHorizontal="true"/>
<ImageButton
android:id="#+id/photo_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="#drawable/ic_action_photo"
android:layout_below="#+id/meal_preview_image"/>
<Button
android:id="#+id/save_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/photo_button"
android:layout_toLeftOf="#+id/cancel_button"
android:background="#ffff001f"
android:text="#string/post_button_text"/>
<Button
android:id="#+id/cancel_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_below="#+id/photo_button"
android:text="#string/cancel_button_text"/>
<Space
android:layout_width="20px"
android:layout_height="20px"
android:layout_alignParentBottom="true"
android:layout_toRightOf="#+id/rating_spinner"
android:id="#+id/space"/>
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editText"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"/>
</RelativeLayout>
</ScrollView>
I have also tried adding "adjustResize" to the manifest file but it didn't do anything.
android:windowSoftInputMode="adjustResize"
Your ScrollView layout height should be wrap_content. Right now it's match_parent which means be as tall as my parent, not; be as tall as the content within me.
I have a lot of info to put on one xml page. Now i got what I want in the positions i want. However instead of fitting all my data on 3 key parts without running into each other, It keeps running into the next TextView. I was wondering how to have it auto adjust.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<Button
android:id="#+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="#string/back" />
<TextView
android:id="#+id/makeup_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/info_title"
android:layout_marginTop="97dp"
android:text="#string/part_section_2" />
<TextView
android:id="#+id/part_info"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/info_title"
android:layout_marginLeft="19dp"
android:layout_marginTop="38dp"
android:text="put text here for info" />
<TextView
android:id="#+id/part_safety"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/part_makeup"
android:layout_below="#+id/safety_title"
android:layout_marginTop="28dp"
android:text="put text here for safety" />
<TextView
android:id="#+id/info_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="42dp"
android:text="#string/part_section_1" />
<TextView
android:id="#+id/part_makeup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="#+id/part_info"
android:layout_below="#+id/makeup_title"
android:layout_marginTop="33dp"
android:text="put text here for makeup" />
<TextView
android:id="#+id/safety_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/part_makeup"
android:layout_marginTop="48dp"
android:text="#string/part_section_3" />
<TextView
android:id="#+id/part_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="16dp"
android:textColor="#b70000"
android:textSize="16sp"
android:text="put text here for part title" />
</RelativeLayout>
would ScrollView work better? and how would switch this from this to ScrollView.
skin is 480x800
density is high(240)
Strings file - http://pastie.org/8534713
Changing to ScrollView (source):
<?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"
android:orientation="vertical" >
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<!-- your Button and TextView widgets -->
</RelativeLayout>
</ScrollView>
Edit:
As well as that, try changing your back button XML to this:
<Button
android:id="#+id/back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/part_safety"
android:layout_centerHorizontal="true"
android:layout_marginTop="50dp"
android:text="#string/back" />
The problem was android:layout_alignParentBottom="true". The bottom ended up not going to the bottom of the page like you had before. The ScrollView cut back on the bottom of the layout.
I'm developing android app as per the following design.
I want to set the height of the scroll view to the remaining screen size (after occupied by header,footer and other texts) although there are no any contents in the list view. When the items added to the list view (dynamically) I want to scroll it withing the same. But now I'm unable to set initial height when there are no items in the list view.
bellow is my layout file.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background_color"
tools:context=".HomeActivity"
android:weightSum="1.0" >
<RelativeLayout
android:id="#+id/relativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:background="#color/header_color"
android:paddingBottom="#dimen/header_vertical_margin"
android:paddingLeft="#dimen/header_horizontal_margin"
android:paddingRight="#dimen/header_horizontal_margin"
android:paddingTop="#dimen/header_vertical_margin" >
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:orientation="horizontal"
android:weightSum="1.0" >
<ImageButton
android:id="#+id/ImageButton03"
android:layout_width="62dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:layout_weight="0.2"
android:adjustViewBounds="true"
android:background="#android:color/transparent"
android:gravity="left"
android:scaleType="centerInside"
android:src="#drawable/title_left_img" />
<ImageView
android:id="#+id/headerImg"
android:layout_width="139dp"
android:layout_height="match_parent"
android:layout_weight="0.7"
android:scaleType="centerInside"
android:src="#drawable/header_img"
android:layout_margin="5dp" />
<ImageButton
android:id="#+id/ImageButton04"
android:layout_width="38dp"
android:layout_height="wrap_content"
android:layout_weight="0.1"
android:adjustViewBounds="true"
android:background="#android:color/transparent"
android:scaleType="centerInside"
android:src="#drawable/title_right_img" />
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/relativeLayout1"
android:paddingBottom="#dimen/body_vertical_margin"
android:paddingLeft="#dimen/body_horizontal_margin"
android:paddingRight="#dimen/body_horizontal_margin"
android:paddingTop="#dimen/body_vertical_margin" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:orientation="vertical" >
<TextView
android:id="#+id/dayText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="TextView"
android:textColor="#color/day_color"
android:textSize="#dimen/day_size"
android:textStyle="bold" />
<TextView
android:id="#+id/dateTimeText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="TextView | TextView"
android:textColor="#color/time_date_color"
android:textSize="#dimen/date_time_size"
android:textStyle="normal" />
<ScrollView
android:id="#+id/scrollView1"
android:layout_width="wrap_content"
android:layout_height="0px"
android:background="#drawable/rounced_rect"
android:layout_weight="1"
android:fillViewport="true" >
<ListView
android:id="#+id/list_tracking"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:dividerHeight="1dp"
android:scrollingCache="true" >
</ListView>
</ScrollView>
</LinearLayout>
</RelativeLayout>
<RelativeLayout
android:id="#+id/relativeLayout3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="1dp"
android:paddingBottom="#dimen/footer_vertical_margin"
android:paddingLeft="#dimen/footer_horizontal_margin"
android:paddingRight="#dimen/footer_horizontal_margin"
android:paddingTop="#dimen/footer_vertical_margin" >
<ImageButton
android:id="#+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="#drawable/track_button"
android:adjustViewBounds="true"
android:background="#android:color/transparent"
android:scaleType="centerInside" />
</RelativeLayout>
I'm new to android app and any guidance is really appreciated.
You can't use a ListView inside a ScrollView.
You could either use a ScrollView or ListView, but not both together or one inside the other.
To summarize my comment:
Remove the unnecessary relativeLayout1, 2, and 3 and scrollView. Then move the bottom image button above the linear layout, so you can make the linear layout position itself with layout_above the image button and give it a height of match_parent. This makes it fill the space between the top linear layout and the bottom image button. And finally make the scroll view's height match_parent so it will also fill the space remaining below the text views.
How can i place two buttons side by side with an image at the bottom of the button?
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="#+id/a_button"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Button-a" />
<Button
android:id="#+id/b_button"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:text="Button-b" />
</LinearLayout>
Instead of using button u can use linear-layout(Clickable) and use its id instead of Button id.something like this...... Using this you can customize your Button as per your requirements.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:orientation="horizontal" >
//Button-A
<LinearLayout
android:id="#+id/a_button"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.50"
android:orientation="vertical"
android:clickable="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal|center_vertical"
android:text="Text-A"
android:paddingTop="10dip"
/>
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/image_A"
android:paddingTop="13dip" />
</LinearLayout>
//For Horizontal partition line
<TextView
android:layout_width="2dp"
android:layout_height="fill_parent"
android:background="#303030"
android:paddingTop="20dip" />
//Button-B
<LinearLayout
android:id="#+id/b_button"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="0.50"
android:orientation="vertical"
android:clickable="true">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text-B"
android:gravity="center_horizontal|center_vertical"
android:paddingTop="10dip" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:scaleType="fitXY"
android:src="#drawable/image_B"
android:paddingTop="13dip"
/>
</LinearLayout>
</LinearLayout>
You can place images at the bottom of buttons with the Drawable_Bottom property.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="#android:attr/buttonBarStyle"
android:orientation="horizontal" >
<Button
android:id="#+id/a_button"
style="#android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="#android:drawable/btn_star"
android:text="Button-a" />
<Button
android:id="#+id/b_button"
style="#android:attr/buttonBarButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableBottom="#android:drawable/btn_star"
android:text="Button-b" />
</LinearLayout>
Just add below line to both your buttons and specify the drawable you want to use.
android:drawableBottom="#drawable/image"
Hope this helps.
EDIT:
Above method works if you want to use your drawables as it is i.e. without modifying its dimensions. If you wish you modify you drawable dimentions as well then you can do that through simple Java code written below:
((Button)findViewById(R.id.button)).setCompoundDrawables(null, null, null, getDrawable(getApplicationContext(), R.drawable.image, 25));
.....
.....
Drawable getDrawable(Context context, int drawable, float form_factor) {
Drawable imgDrawable = context.getResources().getDrawable(drawable);
imgDrawable.setBounds(0, 0, (int)form_factor, (int)form_factor);
return imgDrawable;
}
i want to create an ap that it has a list in the bottom of the page and when i scroll over the screen down, the top of screen disappear and show only the list of elements (and when i scroll up again it show me the top of page again)- the same as in the facebook app..
i tried to implement it and this is my xml with a listview and scrollview, however it doesnt work as expected..
when i scroll page the page stay as is, and only when i scroll the list view , the list view goes down, however the top of the page remain and the list view remain in the same size)
how can i do the same list as in the facebook android app?
thanks alot
<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#ffffff" >
<!-- Header Starts -->
<LinearLayout
android:id="#+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="#layout/header_gradient"
android:paddingBottom="5dip"
android:paddingTop="5dip" >
<!-- Logo Start -->
<!-- Logo Ends -->
<com.facebook.widget.ProfilePictureView
android:id="#+id/profilePictureView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="18dp"
android:layout_weight="1" >
</com.facebook.widget.ProfilePictureView>
<TextView
android:id="#+id/profileNameText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="80dp"
android:layout_weight="1"
android:ems="10"
android:inputType="textPersonName" />
</LinearLayout>
<!-- Header Ends -->
<ImageView
android:id="#+id/freinds"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_below="#+id/detailsText"
android:layout_marginRight="40dp"
android:layout_marginTop="17dp"
android:src="#drawable/logo" />
<ImageView
android:id="#+id/LikeImage"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignTop="#+id/freinds"
android:layout_marginRight="27dp"
android:layout_toLeftOf="#+id/freinds"
android:src="#drawable/logo" />
<TextView
android:id="#+id/detailsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/header"
android:layout_marginTop="16dp"
android:layout_toLeftOf="#+id/freinds"
android:ems="10"
android:inputType="textMultiLine" >
<requestFocus />
</TextView>
<LinearLayout
android:id="#+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="#+id/freinds" >
<Button
android:id="#+id/registerTwitter"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Sale" />
<Button
android:id="#+id/registerFB"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Deliver" />
<Button
android:id="#+id/clearCredentials"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:text="Group" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="#+id/linearLayout1"
android:orientation="vertical" >
<EditText android:id="#+id/EditText01"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:hint="Search">
</EditText>
<ListView android:id="#+id/ListView01"
android:layout_height="wrap_content"
android:layout_width="fill_parent">
</ListView>
</LinearLayout>
</RelativeLayout>
</ScrollView>
I think what you want is a little more complex than just xml layout, but maybe I miss understood, try playing a little with the scroll view events.
you want to display the top of page instantly, when user scroll up, so you need to register to the onscroll event of the scroll view, and check for the scroll direction, to display the top section of the page. is that more clear?