android-layout

Android: can one alias a layout?

I have two Activities that both list items in a table. For the time being both currently use the same layout and then inflate it at runtime. However, to cleanly and strictly separate the two and also allow me to later maybe have slightly different layouts for each, I would like to have two different layout names but simply alias (is th...

Android: Making landscape view without layout-land?

I just want to group 4 buttons like this... Portrait mode: [1][2] [3][4] Landscape mode: [1][2][3][4] I dont want to hardcopy my Portrait mode xml-File and put it into the "layout-land" folder for this minor difference. Then, I have to modify two file when implementing new stuff. Isnt that achievable through wraping it up intell...

Android / Styling a Button: Background also behind Drawable left and Drawable right

I am styling a Button whose width can change in the program through different Content. I got the png files from the designer like this: [Left Border] [Background (just a strip with the gradient)] [Right Border] I thought I'm fine with assigning the Properties of the Button like this: Background: Background.png Drawable left: LeftBor...

Android / 9-patch PNG: What, if I need smth like a 11-patch PNG?

In Draw 9-patch, everything looks fine. However, my SDK says the 9-patch png is malformed. Because I have something like an 11-patch png. Because I don't want the little grabbing area to be scaled. How to get it working? The screenshot describes everything: Error Meassage in Console: ERROR: 9-patch image /res/drawable-hdpi/top_comple...

Android: How to put text underneath a Button?

I have... PNG file for Background PNG file for Icon (drawableTop) Text I want to put underneath this Button It's similar to a Menu Icon. How to do that? I only found following ways. Both of them arent very nice: Make two Buttons, one for Text one for the Picture The Background PNG File needs a transparent area at the bottom in the ...

Android button with different background colors

Hi, i want to change the background-color of a button using a selector-xml-file. My approach is basically the one from the example at the bottom this page: http://developer.android.com/guide/topics/resources/color-list-resource.html i have a res/color/button_text.xml which looks like this: <?xml version="1.0" encoding="utf-8"?> <selec...

Getting the size of an layout in Android

Hi, I have the following layout defined: <LinearLayout> <TextView /> <RelativeLayout> <TextView> <Button> <Button> </RelativeLayout> <LinearLayout> now i want to get the height of the RelativeLayout (i want to specify the height of its children programatically): View rel = findViewById(R.id.RelativeLayout01); in...

Android: Do I just have one shot per property through the use of themes? Is there nothing like CSS in Android?

Here they write: To apply a style definition as a theme, you must apply the style to an Activity or application in the Android manifest. When you do so, every View within the Activity or application will apply each property that it supports. For example, if you apply the CodeFont style from the previous examples to an Acti...

Android: Styles, Includes don't take impact on preview?

Is it normal, that styles and includes don't have any effect in preview in Eclipse? The more I get into Layout building the less I can use the preview. Even in the newest SDK Version it's so poorly made. ...

[Android] How to cover a 9-PATCH-PNG entirely?

I try to implement a hover effect (effect when button is pressed) through putting a semi transparent PNG file on top of the button background and the button icon. Unfortunatly the button background file is a 9-PATCH-PNG which causes some trouble here: It "swallows" everything on top of its layer and doesnt allow to cover the stretchable ...

Android: Something better than android:ellipsize="end" to add "..." to truncated long Strings?

This property makes "short and very-long-word" to "short and" . But I want to have smth. like "short and very-lon..." Right now I truncate the String in Java code. However, thats based on the number of characters and not the actual length of the link. So, the result isn't very nice. String title; if(model.getOrg...

background layout moving when soft keyboard displayed - android

I've got an input popup that I'm displaying over my activities main view that has some edit boxes in it. When the popup is displayed the activities view stays dimmed in the background (like with an alert dialog). The issue I'm having is that when the keyboard comes up the popup is ok, but activities view in the background is shifting up...

Two TextViews side by side, only one to ellipsize?

I want to have two TextView elements appear side by side (in a list item), one aligned to the left, one to the right. Something like: |<TextView> <TextView>| (the | represent the screen's extremities) However, the TextView on the left can have content that is too long to fit on the screen. In this case, I want to have i...

Does android:scaleType="fitCenter" only work with fix Layout_width and Layout_height attributes?

I use Layout_width="fill_parent" and Layout_height="wrap content". If an image is bigger than the ImageView, it will be downscaled perfectly. However, I never got it working to upscale smaller images. I tried any combination of ScaleType and "AdjustViewBounds": it always stays in its own size in the middle of the image view. Here is t...

Android: always show menu bar/static menu bar

Hi there, I would like to use the menu bar instead of a tab bar (tabs are not made for being at the bottom of the view ...). Is there any chance to give the menu bar a static behaviour? Related post: http://stackoverflow.com/questions/2392828/android-set-the-menu-out-visible with the solution: new Handler().postDelayed(new Runnable() {...

Android Layout Resources Question

Hi, I am trying to embed an xml layout resource onto a custom view created in code. So for instance I have an xml file called about.xml i was trying the inflate method, but i am getting a NULL POINTER EXCEPTION CALL and kills my app. in my onCreate method, i am calling linearOut = new LinearLayout(this); linear = new Linear...

Layout in Android?

I got an error error: Error parsing XML: unbound prefix when i did not add an attribute xmlns:android="http://schemas.android.com/apk/res/android" for my Layout. Why we want to set this attribute for a layout?Any Specific Reasons? what i put the url mentioned as a value for xmlns:android. I got the server not found Exception. Please Shar...

How to create small buttons with large text in Android 2.2?

I need to create fixed size sqare buttons with relatively large characters on them for a calculator app. When I increase text size, the character is no more displayed in the center of the button and the button's position gets shifted some pixels to the top (very strange). http://img9.imageshack.us/i/buttontest.png/ If it's possible I d...

[Android] Is it necessary to give each Widget (TextView, LinearLayout...) an Id?

I mean widgets that are not going to be touched through program code. ...

How can I prevent my TextView from overlapping?

How can I prevent this overlapping from occurring without reducing the font size? Here is my 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"> <TextView android:id="@+id/na...