Android :: Setting Layout Attributes Based On OS Version?

Sep 14, 2010

Is there a way to specify a background in a layout based on OS version?:

android:background_1.5="@color/white"android:background_above_1.5="@drawable/mybackground"

I'm running into a problem where using a 9 png drawable for the background causes a stack overflow exception on a listview item (stack trace shows its related to a child TextView -> drawText()). The layout is simple:

<LinearLayout><ImageView /><TextView /></LinearLayout>

and the background works fine on 1.6 and above. It's just 1.5 that's having the issue. If I set the background to be a color, it works fine.

Android :: Setting layout attributes based on OS version?


Android :: Weight Sum - Layout Attributes Not Working

Nov 26, 2009

I have a simple horizontal linear_layout with bunch of image views in it. the trick is that the views have different widths, relative to the size of their parent (the linear layout). I set the layout's weightSum to a 100 and the layout_weight to let's say 10 of one view and 15 of the other, on so on. And it did not work. I also tired using float values setting the weightSum to 1.0 and the layout_weight of the image views to 0.2 and 0.3 and so on. But it didn't work either. I did search this group for any references to the weightSum but found nothing. Any ideas how to handle it?

View 5 Replies View Related

Android :: Custom Widget - Attributes In The Layout Xml Files

Aug 6, 2010

I have defined custom views in the various layout .xml files. However, all the layouts are using the Linear Layout - put the content would vary.

I would like to create my own widget tag something like <com.mypackage.MyLinearLayout />, I would like to pass the layout as a param to the <com.mypackage.MyLinearLayout layout="@layout/simple.xml" />

How to define new attributes to the custom widgets ? Simply defining a getter/setter method would work or is there any other references.

View 2 Replies View Related

Android :: Using Resource Values As Layout Attributes - Config.xml

Mar 28, 2010

Looking in the android sdk folders, I've found a file called values/config.xml. This seems to be somewhere that you can define values for later use in layouts and animations.

Given the config.xml:

<resources>
<string name="config_somePadding">50dip</string>
</resources>

How would I reference this to use as the layout_height in a layout xml file?

@string/config_somePadding is actually the only one I've found that doesn't throw an error in Eclipse (even though there isn't a config_somePadding in values/strings.xml), but it appears to just put an empty string.

In the sdk, they use an integer for animation duration. They reference it like this: android:duration="@android:integer/config_longAnimTime". Is there a way to use values that aren't integers in the layout_height attribute?

View 1 Replies View Related

Android :: Setting Attributes Of An EditText Added Dynamically In Phone

Nov 17, 2010

I am developping an android app which downloads an xml and displays a layout with a number of edittexts, checkboxes, spinners, etc. added dynamically like this:

LinearLayout ll = new LinearLayout(this);
EditText nameField = new EditText(this);
ll.addView(nameField);
ScrollView sv = new ScrollView(this);
sv.addView(ll);
setContentView(sv);

I'm having trouble with setting some properties to an EditText added this way. For examle android:maxLength attribute can easily be set in an xml layout but I found no method to do the same in the java code. How can I do it when hawing to add dynamically?

View 2 Replies View Related

Android :: Relative Layout XML Attributes Have No Obvious Programmatic Equivalent

Jun 16, 2009

If a RelativeLayout must be generated at run time, what are the equivalent API calls for the attributes set in the XML Layout editor? Take for example this very simple RelativeLayout that places the second ImageView to the right of the first ImageView:

<?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"
android:orientation="horizontal" android:background="@drawable/ bg_sunrise"
android:layout_gravity="center" android:gravity="center">
<ImageView android:id="@+id/ImageView01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/icon"></ ImageView>
<ImageView android:id="@+id/ImageView02" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_toRightOf="@id/ ImageView01" android:src="@drawable/icon"></ImageView> </RelativeLayout>

Of the many, variations I tried, I had the most hope for this one, but it didn't work either:

protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
RelativeLayout layout = new RelativeLayout(this);
layout.setLayoutParams( new ViewGroup.LayoutParams (
LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT ) );
ImageView imageView1 = new ImageView(this);
imageView1.setImageResource(R.drawable.icon);
imageView1.setAdjustViewBounds(true);
// set the ImageView bounds to match the Drawable's dimensions
RelativeLayout.LayoutParams params1 = new RelativeLayout.LayoutParams (LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params1.addRule(RelativeLayout.ALIGN_PARENT_TOP); layout.addView(imageView1, params1);
ImageView imageView2 = new ImageView(this); imageView2.setImageResource(R.drawable.icon);
imageView2.setAdjustViewBounds(true); // set the ImageView bounds to match the Drawable's dimensions
RelativeLayout.LayoutParams params2 = new RelativeLayout.LayoutParams
(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
params2.addRule(RelativeLayout.RIGHT_OF, imageView1.getId());
layout.addView(imageView2, params2); this.setContentView(layout); }

Can anyone offer the Java equivalent to the above XML? Can anyone explain why there is no attribute, getter/setter, or method for accessing the properties that can be set in XML? What is the most elegant solution for dynamically creating Layouts, Views, and other Resources on the Android platform when there is no Java programmatic equivalent?

View 11 Replies View Related

Android :: Way I Can Load Class Based On SDK Version?

Jun 7, 2010

Is there any way I can load a class based on what version of the OS the phone is running? For example:

I made an app which requires 1.6+ Android. Is there a way for me to load one class or the other based on what OS the phone is running? I'm asking this specifically for contacts. The database was changed from 1.6 to 2.0 and the old version doesn't retrieve contacts on the new OS phone. I'd still like to keep my 1.6 requirement, but at the same time I'd like 2.0+ phones to access the contact part of the app.

So can I make 2 APIs, somehow pack them with the app and decide on the fly which I choose to import?

View 2 Replies View Related

Android :: Setting For Poxy Based Network Connections

Jul 16, 2009

Can anybody give me the Exact methodology for Connecting through Android Browsers and also Exact way for making the Map application work in my "Proxy Networked Machine"

None of the methodology in the below are working for me....

1. placing the http_proxy in settings.db 2. -http-proxy in console

View 2 Replies View Related

Android :: Setting Wallpaper Based On User Inputs

Aug 3, 2010

I am developing a simple app that sets wallpapers based on some user inputs' I am almost done with my app, I am only missing the code for setting wallpapers. I have been looking for it in lots of websites in vain. Can anybody post a sample code that sets as a wallpaper a drawable that is saved in res folder.

View 2 Replies View Related

Android :: ]Setting Button Height In XML Based On It's Width?

Oct 15, 2010

I am working on layout in android XML in which I would like to set a buttons height to match it's width when setup to fill parent. Obviously this number will change based on screen size, so I cannot use a set pixel size. Can someone help me with getting the button width based on screen size and then passing that to the height setting?

View 2 Replies View Related

Android :: Which Layout To Use For 2x2 Image - Based Menu?

Nov 3, 2010

I am trying to create a screen (in portrait mode) that shows 4 images (same size, intended to scale down to fit screen), taking up the entire screen, breaking up the screen into quadrants (a tall, 2x2 grid). This will act as a main menu type of activity and each image should be clickable, in order to take the user to a different activity.

I have tried using a GridView inside a LinerLayout (using a lot from Google's GridView tutorial) but cannot get the images to all scale properly to fill the entire screen. I get extra margins around the images and/or scrolling of the entire screen. I have also tried using a TableLayout, placing 2 images in each of the 2 rows. Visually, that worked perfectly. Unfortunately when using that, I cannot seem to reference the ImageView items in the TableLayout in my activity code (findViewById always returns null)..................

View 1 Replies View Related

Android :: Why Does This XML-Layout Based Application Crash

Sep 14, 2010

I am very new to Android Development. I am trying a sample application and it is generating a button dynamically using Java and it is working fine.

This works fine in my emulator. However when i try do with an XML based layout, my app crashes in the emulator.
Main.XML contents
<?xml version="1.0" encoding="utf-8"?>
<Button xmlns:android="com.testing"
android:id="@+id/button"
android:text=""
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
Code:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.main);

btn=(Button)findViewById(R.id.button);
btn.setOnClickListener(this);
updateTime();}

Does anyone know why this simple application is crashing because of the XML layout?

View 2 Replies View Related

Android :: Creating A Custom Image Based Layout?

Sep 26, 2010

Is it possible to create a layout based on (background) images? For example, there is well know app called Appie that uses this picture as a homescreen:

I might be able to recreate the layout with a TableLayout, but this will be difficult to get it perfectly aligned with the buttons in the image. The default layout options make it very difficult, or maybe impossible, to allow for selection of the buttons on the image (especially when the buttons are in an arc-path). Can anyone tell me how this is done?

View 1 Replies View Related

Android :: Displaying XML-based Layout / Adding Text Dynamically

Sep 12, 2009

I have a LinearLayout defined in XML that I want to use repeatedly to display elements of a list. The XML-layout looks like this:

<?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="wrap_content"
android:background="@drawable/background"
android:paddingBottom="5px">

<TextView
android:id="@+id/destination"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="22dp"
android:text="@string/test_destination"
android:paddingLeft="5px"/>

<TextView
android:id="@+id/date"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="15dp"
android:text="@string/test_date"
android:paddingLeft="5px"/>

<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/info"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingLeft="5px"
android:paddingTop="10px" >

I gather information about certain events from a webpage, and then I want to display all events in a list using the above layout for each event. My current approach is to have a LinearLayout as parent and then adding each event as a row.

Problem number one is to add the layout to each event (the number of events is varying). I.e., I want to dynamically inflate this layout for each event. I also don't want the text to be hard coded into the layout (as above) but added at runtime. I don't know how to do this. I have tried something like the following without any success.

LinearLayout eventView = (LinearLayout) findViewById(R.layout.event);
parentView.addView(eventView);


Problem number two is then to add these layouts to the parent view group and display it on the screen. When I try to do this using parent.addView(child), the program crashes at runtime and I can't figure out why.

It's kind of hard to describe the specific problem, since I'm new to GUI-programming on Android and I'm sort of programming by trial and error right now. Anyway, if you are able to help me with some of the problems it would be greatly appreciated. Linus

EDIT:
The problem now is adding text dynamically to the TextViews. I try this:

TextView dest = (TextView) findViewById(R.id.destination);dest.setText("myText");

only to discover that dest is null. Any ideas why and how to fix this?

EDIT 2:
I have narrowed the problem even more, but I really don't understand its nature. This is the trouble-method: Code...
it somehow works (even though the events are displayed in reverse order). Anyone knows what's going on here?

View 2 Replies View Related

Android :: Dynamically Adjust Column And Row Of A Table Layout Based On Orientation

Mar 9, 2010

Is it possible for my android application to dynamically adjust the no of column and no of row of my TableLayout based on orientation?

For example, when in landscape mode, the TableLayout is 3x2 and when
in portrait mode, the TableLayout is 2x3?

View 1 Replies View Related

General :: Setting Preferred WiFi Connection Based On SSID?

Dec 17, 2012

Any app which allows to set the preferred wifi network to connect to?

specifically, I want my phone to always connect to network "A" whenever it becomes available, and even if it is currently connected to other networks with a stronger signal.

View 1 Replies View Related

Android :: Setting MaxSDK Version For 1.5 App

Apr 30, 2010

I've released an android app with the property

<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="4"/>
now my app seems to crash on android 1.5 devices (i guess because i use drawable-mdpi/hdpi,...)
so thought it would be good to release the same app just for 1.5 devices (not using the mdpi/hdpi-directories). but when i use
<uses-sdk android:minSdkVersion="3"
android:targetSdkVersion="3"
android:maxSdkVersion="3" />


it doesn't compile for 1.5 (it states that target and maxsdkversion are unknown properties).
(if i set the jar-sdk to 1.6 it works fine).

So what is the best way to solve my problem? Is the app runable if I compile with 1.6 sdk but restrict it to sdk 3 (1.5) ? Or would this also crash since the sdk3 doesn't know the manifest-attributes "target/maxSdkVersion"? Any other ideas how to solve this?

View 1 Replies View Related

Android :: Setting Layout XML File To New Activity

Aug 18, 2009

I created a new Activity and created a new layout file under res/ layout . after this,i also want to add a options menu file under res/menu.but how could i bind all these layout file with this Activity? I can't find any info in manifest file. or i missed it?

View 3 Replies View Related

Android :: Trying To Add Image - Setting Layout Parameters

Jul 21, 2010

So Im trying to add an imageview to my current xml design - and its working decently. Now my main problem is that I cant seem to find a way to set the attributes for the image like where it needs to be displayed etc.

RelativeLayout mRelativeLayout = (RelativeLayout) findViewById(R.id.board);

ImageView i = new ImageView(this);
i.setImageResource(R.drawable.blue_1);
i.setAdjustViewBounds(true);
mRelativeLayout.addView(i);
setContentView(mRelativeLayout);

i tried messing around with setlayoutparams but got absolutely no clue what to do with it.

View 1 Replies View Related

Android :: Is There Setting Text To Display Layout

Nov 18, 2010

simple question. In a class, if I wanted to set the text to the text value of a string I have, what is the code for that?

I have: TextView textView = (TextView) findViewById(R.string.noFaceFive); textView.setText(textView);

but setText says : The method setText(CharSequence) in the type TextView is not applicable for the arguments (TextView)

is there a set Text to display the text of a string? Serious mind fart on my part.

View 1 Replies View Related

Android :: Layout When Setting WindowIs Floating To True?

Mar 3, 2010

I've got a ListActivity using the Theme.Dialog theme and windowNoTitle set to true.

Unfortunately, when I do this, the header rows (just normal rows in the list but they look like sub headers) refuse to fill_parent width (instead, they wrap_content - the header text).

I noticed this was not a problem when using the Theme theme so I started narrowing everything down to what was causing the problem.

The answer: windowIsFloating. Theme.Dialog sets this to true, and if I override this to false, then the headers happily fill the parent width.

Is there a way around this (because I would like to set windowIsFloating to true)?

View 8 Replies View Related

Android :: Custom View Extending View-Class / Still Based On XML-Layout

Aug 17, 2010

I want to build my own custom view which should look like the Crysis-GUI.At first I designed a XML-based Layout and made it visible via the setContentView(int resid)-Method. Worked pretty well.But now I wan't to go a step further and draw in my Layout. So I created a new Class, let it extend View and overrode the onDraw()-Method. So far so good.But how can I still use my XML-Layout? I can't do setContentView anymore, so how could the same effect be achieved?

View 1 Replies View Related

Android :: Setting Background Color On Row Layout Prevents Display Of Highlight On Select

Jun 16, 2010

I'm setting background color based on a given state of an object in each row in a list. That part is working just fine but when I set the background color on the outermost layout the row no longer highlights when selected. Probably a specific attribute I'm not setting/changing?

View 3 Replies View Related

Android : Setting A Layout To Use As Empty View For A ListView In Case Adapter Has Zero Items In A Activity

Nov 16, 2010

How to use a layout as empty view for a listview when the adapter has zero elements?

setEmptyView is not working with this code :

CODE:..............

Layouts used :

CODE:...........

main.xml

CODE:...............

View 3 Replies View Related

Sony Ericsson Xperia X10 :: Keyboard Layout Setting

May 10, 2010

so hopefully this question/problem isn't as simple/dumb as my previous.I've somehow messed up my keyboard settings or language. the bottom right and bottom left buttons now have some Chinese/Japanese text on them and the bottom left button turns on some alternative keyboard options and changes my text output to Japanese.Now I presumed this was simply something in my language settings but I've set them back to UK and still no joy.I'm also using Handcent sms and the Handcent keyboard ui but that's not displaying either. Tried un-install/reinstall but no luck.

View 1 Replies View Related

HTC Magic :: Change Keyboard Layout On Phone To Abc Version / Need Good Apps And Games

Feb 21, 2010

I would like to see if there is anyway of changing the keyboard layout on the magic to the abc version if so how do you do it?

also is there any good games or apps that anyone knows?

View 2 Replies View Related

Android :: How To Set Same XML Attributes To All Activities ?

Dec 7, 2009

In my application, I don't want the activity to restart when user changes his mobile's orientation or when he opens his physical keyboard.So, I have to assign the following XML attribute to all my activities in the manifest file.Is it possible to assign the same XML attribute value to all activities ? Or should I copy the attribute in all the <activity> tags of the manifest?

View 3 Replies View Related

Android :: How To Set Xml Attributes In Code

Nov 5, 2009

I met a problem in setting xml attribute at run time.

For example I define a xml layout like this:

CODE:.......................

I want to set android:drawableLeft="@drawable/icon" at runtime.But thers has no setter method for this attribute.

View 2 Replies View Related

Android :: Custom Xml Attributes For PreferenceScreen

Sep 26, 2010

I use custom xml attributes for preferences. The preferences are inflated from xml.I managed to create and read custom xml attributes for EditTextPreference, ListPreference and CheckBoxPreference by creating custom classes which inherit from the respective preference class.My problem is that I can't do this for the PreferenceScreen class, as it is a final class. So my question is: Is there any way I can read the custom attributes of a PreferenceScreen?

View 1 Replies View Related

Android :: Scrollview Dropshadow Attributes Available?

Feb 5, 2010

can i affect the look of the dropshadow that the scroll view shows when there's "more" available via scrolling? i'm not seeing anything in the scrollview docs.

View 4 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved