Disappearing Views - android

I have a fairly standard layout for the first screen of the setup wizard on my app. I have been developing it with a solid color background which I defined in a theme. I have recently got a png file that I would like to used as the background. This works fine on all screens apart from the 3 screens for the setup wizard. The problem being that only the first textview is drawn. I used the hierachy viewer and the other views where not listed.
These are the only screens that use an include statement so I suspect this may be the root of the problem but even if I take out the include statement I still have the problem.
<?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">
<TextView
android:id="#+id/welcome"
android:text="#string/welcome"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:gravity="center_horizontal"
android:textColor="#433A33"
android:textStyle="bold">
</TextView>
<ImageView
android:id="#+id/mainIcon"
android:src="#drawable/main_icon"
android:layout_width="100dip"
android:layout_height="100dip"
android:layout_centerHorizontal="true"
android:layout_below="#+id/welcome">
</ImageView>
<TextView
android:id="#+id/description"
android:text="#string/description"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="#+id/mainIcon"
android:gravity="center_horizontal"
android:textColor="#433A33"
android:textSize="15dip">
</TextView>
<TextView
android:id="#+id/choice"
android:layout_below="#id/description"
android:text="#string/choice"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:gravity="center_horizontal"
android:textColor="#433A33"
android:textSize="15dip">
</TextView>
<Spinner
android:id="#+id/language"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#id/choice"
android:prompt="#string/languagePrompt"
android:textSize="10dip"
android:layout_marginRight="20dip"
android:layout_marginLeft="20dip">
</Spinner>
<include layout="#layout/wizard_bottom" android:layout_width="wrap_content" android:layout_height="wrap_content"/>
</RelativeLayout>
Let me know if anybody has any ideas.
Edited to show the problem with a screen shot

The problem was that the theme I was using was setting the background to all Views rather than just the window background. So the background that is in the screen shot is the background for that one imageView and all the other views where pushed off the page.
I changed the them accordingly and it working fine now

Related

Button's text is only half visible

I am having troulbe fixing the following issue. I have a button with text OK. The button is nested inside a LinearLayout. This layout is nested inside two RelativeLayout. The second/inner RelativeLayout has `android:layout_margin="15dp". This is causing the text inside the button to be only half visible.
The XML is below. I am using it because it gives me the "popup" dialog with the (X) button on the top right corner.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
<RelativeLayout
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:padding="2dp"
android:background="#drawable/xml_round_corners_background"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="15dp"
android:background="#drawable/xml_round_corners_background"
android:gravity="center_vertical|center_horizontal"
android:layout_weight="1"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_weight="1"
>
<TextView
android:id="#+id/exitTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|center_horizontal"
android:textAlignment="center"
android:text="TEXT....\n\n\n"
android:textColor="#color/white"
/>
</LinearLayout>
<LinearLayout
android:layout_weight="1"
android:id="#+id/bluetooth_error_button_linearlayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:layout_below="#+id/exitTV"
>
<Button
android:layout_margin="15dp"
android:id="#+id/bt_error_message_ok_button"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#drawable/xml_botton1"
android:text="OK"
android:textColor="#color/DarkMagenta" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>
<Button
android:id="#+id/bt_error_message_x_button"
android:layout_alignParentRight="true"
android:text="X"
android:textColor="#FFF"
android:background="#drawable/xml_round_dismiss_button"
android:gravity="center_vertical|center_horizontal"
android:layout_margin="7sp"
android:layout_height="30sp"
android:layout_width="30sp"
android:textSize="15sp"
android:textStyle="bold"
android:onClick="cancelActivity" />
</RelativeLayout>
Could anyone please tell me what can i do to make the text fully visible?
I have changed/addded/removed attributes to the LinearLayout and the RelativeLayout the TextView, and the Button as well. but I could not make it work.
Thanks
EDIT:
This photo is how Eclipse shows the window, and its actually how I want it to be.
This is a partial screen shot from my phone. Samsumg Galaxy S III mini (4.0" screen)
I jsut realized that I was using another XML file as the background for each button. This XML was causing those issues.
rather than try to "text" with "background" in your XML, try using drawableTop (or ~Left ~Right or ~Bottom). These set the text so that the drawable is above "drawableTop" your text or where ever you want it

Custom Header in Mono for Android App

I'm working on my first app using Mono for Android. I feel like I'm trying to do something basic but I'm not having any luck. Essentially, I want to have a custom "banner" at the top of my app. The banner is simply a black rectangle with two words: "Hello" and "World". Hello is in red, and World is in Blue.
I'm not getting anywhere with this. Does anyone know how to do this?
Thank you!
Here is a very basic layout example to get you started.
<?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" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#000000"
android:padding="5dp" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="2dp"
android:text="Hello"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#FF0000" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="World"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#0000FF" />
</LinearLayout>
<!-- The rest of your activity layout goes here. -->
</LinearLayout>

How do I fix the layout size with a background picture properly in Android?

I need help with my layout.xml file size. I am probably missing something basic. I have created a search-function with a EditText, SearchButton and a ListView where I will display the search results.
Everytime you click on the EditText I need to make sure the background picture does'nt get resized when the softkeyboard is displayed, therefor my whole layout is placed in a ScrollView. That's basicly the only reason why I am using a ScrollView. But the ScrollView creates another problem aswell, look at the picture below:
http://tinypic.com/view.php?pic=6p3yix&s=6
For some reason my background picture refuses to fill the whole "background" area. Look at the bottom of the picture where it is black. So when I am testing on a phone with large screens it gets black at the bottom. How can I manage to fill the whole "background" area with my background-picture? Please help!
Edit: I have tested to use the layout.xml file without a ScrollView but have not made it work since without it, the the keyboard will change the size of the background picture. I have also tryed to use adjustPan in the android manifest file without any luck. Only solution that worked is with ScrollView, but now instead I get this problem with the background-pictures size... / Thanx!
My xml file:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:id="#+id/sorted_teams_scroll"
android:isScrollContainer="false">
<TableLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_search_task"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center|top"
android:orientation="vertical"
android:stretchColumns="1"
android:weightSum="1.0"
android:background="#drawable/orginalbild01"
>
<TableRow>
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.05">
</TextView>
<EditText
android:id="#+id/search_task_field"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.65"
android:hint="#string/SearchTaskHint" />
<Button
android:id="#+id/search_task_button"
android:layout_width="0dip"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:layout_weight="0.25"
android:text="#string/Search" />
<TextView
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.05" >
</TextView>
</TableRow>
<TableRow>
<TextView
android:layout_width="wrap_content"
android:layout_height="5dp" >
</TextView>
</TableRow>
<TableRow android:paddingLeft="40dp" >
<TextView
android:id="#+id/search_task_column_names"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:textStyle="bold" >
</TextView>
<TextView
android:id="#+id/search_task_column_names1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:textStyle="bold" >
</TextView>
<TextView
android:id="#+id/search_task_column_names2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_weight="0.33"
android:textStyle="bold" >
</TextView>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center">
<ProgressBar
android:id="#+id/search_task_progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:indeterminateOnly="true"
android:visibility="gone" />
</TableRow>
<TableRow
android:paddingLeft="18dp"
android:paddingRight="18dp"
>
<ListView
android:id="#+id/search_task_list"
android:layout_width="fill_parent"
android:layout_height="355dp"
android:gravity="left" />
</TableRow>
</TableLayout>
</ScrollView>
If you have problem only with keyboard then...
just try this to disable the layout resize when keyboard is popped up -
In your manifest file add this to your activity...
android:windowSoftInputMode="adjustPan"
Pls post complete code... in above code you set background for table layout.. how it will apply for full background.. post your code without scrollview...

android - another android UI question

I have a scrollview ( mainly for landscape purposes, as I don't have a different xml file, I'm using android:configChanges="orientation")
which contains a RelativeLayout and within it there's a Linear Layout.
The code looks like this:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="#color/background"
android:padding="10dip" android:layout_width="fill_parent"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout android:layout_height="fill_parent"
android:layout_width="fill_parent">
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_gravity="center"
android:orientation="vertical">
<TextView android:textSize="24.5sp" android:textStyle="bold"
android:layout_height="wrap_content" android:layout_gravity="center"
android:text="#string/main_title" android:layout_width="wrap_content">
</TextView>
<ImageView android:src="#drawable/icon"
android:layout_marginTop="20px" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="center" />
<TextView android:textSize="15sp" android:layout_marginTop="20px"
android:layout_height="wrap_content" android:text="#string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="#+id/spinner"
android:prompt="#string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<Button android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="#+id/start_button"
android:text="#string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="#+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginTop="20px" android:id="#+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
</LinearLayout>
<ImageView android:id="#+id/info_button" android:src="#drawable/info"
android:layout_alignParentBottom="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</RelativeLayout>
</ScrollView>
Everything works fine, both in portrait and loandscape mode except for the ImgView (info_button) at the very end.
I used a Relative Layout because I thought I'd be able to position it on bottom right hand corner (a bit of margin would be desirable bottom and right) of the screen...
This is what I get instead...
http://www.doc.ic.ac.uk/~am907/wrong.png
any help appreciated!
EDIT: The link to the full XML file http://pastebin.com/Cce4AC4v (for some reason I can't see it all in preview mode but it's there when I try to re-copy in the text form)
Thanks
andreas
Instead of:
android:layout_gravity="bottom|right"
Try:
android:layout_alignParentRight="true"
Edit: Reading your question again, I believe the problem is the ScrollView. I'm not sure why you are using this type of layout. You could get rid of it in favor of the relative layout and that should solve your problem. I'm not sure why you feel this activity needs to support landscape. If so, I would boil the ScrollView down to a single view object and try to troubleshoot that.
I have understood that u want to place that image at bottom - right location. If so, then give:
<ImageView android:id="#+id/info_button" android:src="#drawable/info"
android:layout_alignParentBottom="true" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_alignParentRight="true" />
If this is not the solution, could you place ur desired screen to be prepared, so that we can cross check ur layout.

android - linearlayout in scrollview

Since my UI is quite simple I'd like to cater for both landscape and portrait in one xml file.
In portrait mode everything is as I exactly want it to be.
In landscape the main_title TextView is barely shown. Is there a work around for this?
<?xml version="1.0" encoding="utf-8"?>
<ScrollView android:background="#color/background"
android:layout_width="fill_parent" android:padding="20dip"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout android:layout_height="fill_parent"
android:layout_gravity="center" android:orientation="vertical"
android:layout_marginTop="30dip" android:id="#+id/LinearLayout01"
android:layout_width="fill_parent">
<TextView android:layout_marginBottom="15dip"
android:textSize="24.5sp" android:layout_height="wrap_content"
android:id="#+id/TextView01" android:layout_gravity="center"
android:text="#string/main_title" android:layout_width="wrap_content"></TextView>
<Button android:layout_marginBottom="15dip"
android:layout_height="wrap_content" android:id="#+id/start_button"
android:text="#string/start_label" android:layout_width="fill_parent"></Button>
<TextView android:textSize="18sp" android:layout_height="wrap_content"
android:id="#+id/TextView02" android:text="#string/time_window_please_select_label"
android:layout_width="wrap_content"></TextView>
<Spinner android:layout_height="wrap_content" android:id="#+id/spinner"
android:prompt="#string/time_window_prompt" android:layout_width="fill_parent"></Spinner>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="#+id/status_label"
android:layout_width="wrap_content"></TextView>
<TextView android:layout_height="wrap_content"
android:layout_marginBottom="10dip" android:id="#+id/status_time_label"
android:layout_width="wrap_content">
</TextView>
<ImageView android:layout_marginTop="60dip" android:id="#+id/info_button"
android:src="#drawable/info" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_gravity="bottom|right" />
</LinearLayout>
</ScrollView>
Links:
http://www.doc.ic.ac.uk/~am907/landscape.png
http://www.doc.ic.ac.uk/~am907/portrait.png
looks like the problem lies with your margin and padding values.
best option may be to have 2 different layouts for this, 1 being portrait and other being landscape. create another folder named layout-land and layout-port in your res folder. then copy the layout file into both of these folders and make appropriate changes for the orientation.
see the android docs for more info about providing different resources for different orientations and so on: http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources
add a blank textview at the top of the file, ie above the textview which is not visible. maybe your content area is very big and the screen is not able to support it. The problem that you are facing should not be happening in the first place.... but this is a work around. Also try switching emulators...

Categories

Resources