Tag: layout

ImageView in android XML layout with layout_height=“wrap_content” has padding top & bottom

I have a vertical LinearLayout containing an ImageView and a few other layouts and views. <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent”> <ImageView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:contentDescription=”@string/banner_alt” android:src=”@drawable/banner_portrait” /> <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:text=”@string/main_search” android:gravity=”center” android:textStyle=”bold” /> <LinearLayout android:orientation=”horizontal” android:layout_width=”match_parent” android:layout_height=”wrap_content” > <Spinner android:id=”@+id/search_city_spinner” android:layout_width=”0px” android:layout_height=”wrap_content” android:layout_weight=”1″ android:prompt=”@string/search_city_prompt” android:entries=”@array/search_city_array” /> <Spinner android:id=”@+id/search_area_spinner” android:layout_width=”0px” android:layout_height=”wrap_content” android:layout_weight=”1″ android:prompt=”@string/search_area_prompt” […]

Error referencing an inner class View in layout/main.xml

Grrr… I create a subclass of view as an inner class in my Activity. Before I simply linked to this view from my activity with: setContentView(new CustomView(this)); without problems. Now, however, my view is getting more complex so I am making it part of a FrameLayout so that I can make this the base view […]

Vertical content align in Android EditText

I have a multi-line EditText: <EditText android:layout_gravity=”center” android:id=”@+id/txtMessage” android:layout_height=”wrap_content” android:layout_below=”@+id/lblMessage” android:layout_width=”wrap_content” android:width=”250dip” android:text=”” android:maxLength=”760″ android:lines=”4″> </EditText> Now the content is aligned to the middle. And I’d like to have the content aligned to the top like this: vertically aligned text example http://img28.imageshack.us/img28/3972/edittext.png Is there a property to do that?

Getting android.content.res.Resources$NotFoundException: exception even when the resource is present in android

Please let me know where I am going wrong to get the error I am creating an app which have one of its activity to be only in landscape mode. So I added the following in AndroidManifest.xml file <activity android:name=”.LandScapeImageActivity” android:screenOrientation=”landscape”></activity> I have created a folder like /res/layout-land and add a layout called see_today_landscape_layout in […]

Android layout folders: layout, layout-port, layout-land

I’m not sure to have understood well the role played by the several Android /res/layout folders. layout: general layouts layout-port: layout for widget that must change for portrait orientation layout-land: layout for widget that must change for landscape orientation For example in the Home sample application, under layout-port and layout-land folders there is only one […]

How do you setLayoutParams() for an ImageView?

I want to set the LayoutParams for an ImageView but cant seem to find out the proper way to do it. I can only find documentation in the API for the various ViewGroups, but not an ImageView. Yet the ImageView seems to have this functionality. This code doesn’t work… myImageView.setLayoutParams(new ImageView.LayoutParams(30,30)); How do I do […]

Android: can height of SlidingDrawer be set with wrap_content?

I’m trying to implement a SlidingDrawer that will occupy the full screen width, but whose height is determined dynamically by its contents: in other words, standard fill_parent layout behaviour for the width and wrap_content for the height. That’s exactly how I’ve specified it in the layout XML (see below) but the sliding drawer always opens […]

Android: How can you align a button at the bottom and listview above?

I want to have a button at the bottom of the listview. If I use relativeLayout/FrameLayout, it aligns but listView goes down to very botton. (Behind the button at the bottom) FrameLayout: <?xml version=”1.0″ encoding=”utf-8″?> <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”fill_parent” android:layout_height=”fill_parent”> <ListView android:id=”@+id/listview” android:layout_width=”match_parent” android:layout_height=”wrap_content” /> <FrameLayout android:layout_width=”wrap_content” android:layout_height=”match_parent” android:layout_alignParentBottom=”true”> <Button android:id=”@+id/btnButton” android:text=”Hello” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_gravity=”bottom” […]

Android: How to make all elements inside LinearLayout same size?

I would like to create a dialog to display a video title and tags. Below text I would like to add buttons View, Edit and Delete and make these elements same size. Does anyone know how to modify .xml layout file in order to make elements inside LinearView same size? The current layout file looks […]

Android overlay a view ontop of everything?

Can you overlay a view on top of everything in android? In iPhone I would get the new view set its frame.origin to (0,0) and its width and height to the width and height of self.view. Adding it to self.view would then cause it to act as an overlay, covering the content behind (or if […]

Android Babe is a Google Android Fan, All about Android Phones, Android Wear, Android Dev and Android Games Apps and so on.