Tag: layout

Android: How to create this simple layout?

I need to create a simple layout with two form widgets (for example – two buttons). The first one must fill all available width of the parent layout and the second one must have some fixed size. That’s what I need: If I set FILL_PARENT to the first widget – I don’t see the second […]

Android Scrollview having videoview is giving problem

I have a VideoView that is inside a scrollView. When I scroll the scrollView, the VideoView does not scroll with it. It is like its position is fixed. Here is my layout: <?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=”fill_parent” android:background=”#FFFFFF”> <LinearLayout android:id=”@+id/BackBar” android:orientation=”vertical” android:layout_width=”fill_parent” android:paddingTop=”2dp” android:layout_height=”wrap_content” android:background=”#D6DEAA”> <Button android:id=”@+id/BackButton” android:layout_gravity=”left” android:text=”@string/BackButtonText” android:layout_width=”wrap_content” android:layout_height=”wrap_content” […]

What is the difference between addView and addViewInLayout

I have seen some widgets using addView and sometimes addViewInLayout. What is the difference between them? What will happen if I replace one with the other? Should I keep a flag during layout and use “addViewInLayout” or “addView” accordingly? Thanks. BR, Henry ps. add more tags: removeview, removeviewinlayout

Why my TableLayout isn't allowed to be inflated?

For a widget I use a simple layout which contains a TableLayout <?xml version=”1.0″ encoding=”utf-8″?> <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content”> <TableRow > (…) </TableRow> </TableLayout> But when a I want to update its content by creating a RemoteViews RemoteViews eventElementLayout = new RemoteViews( this.getPackageName(), R.layout.widget_events_element ); I got an exception telling me that TableLayout is not […]

Give padding with setPadding with dip unit not px unit

The method public void setPadding (int left, int top, int right, int bottom) someview.setPadding(1,1,1,1); this will give padding with 1px in each side. How can I give 1dip instead of 1px ? the values fro left , top right and bottom are in pixels , how can I give values programatically in code in dip […]

Android Multi-Screen Application

How do you handle multiple screens in an android application? I have developed with the tab bar at the bottom without problem, however what I am wanting to do is replace all the content on the screen with the content from a new .xml layout file I have created in the project. Additionally, how would […]

Android Relative Layout with sticky footer

I’m relatively new to Android development and I’m having a hard time putting together a certain interface. I’ve looked through many similar questions but none of them give me the answer i’m looking for. I want to put together an XML interface like the following: I want a LinearLayout that acts like a sticky footer […]

why can't I override layout properties of included layouts in my Android project?

I am attempting to create some modular UI elements as described at Android Developers – Creating Reusable UI Components, unfortunately I’m not getting the desired result. The article states: you can override all the layout parameters. This means that any android:layout_* attribute can be used with the tag. My XML code looks like this (relevant […]

How to load programmatically a layout XML file in Android?

I have made a layout (say my_layout.xml) which includes programmatically two other XML layout files, say some_layout.xml and another_layout.xml. my_layout.xml is drawn using setContentView(R.layout.my_layout). Now I have a checkbox with ID some_checkbox, which is defined inside some_layout.xml, and I want to give the checkbox an OnCheckedChangeListener using setOnCheckedChangeListener(), just like this: CheckBox cb = (CheckBox) […]

FrameLayout inside of ScrollView

I’m new to android development and I have the following problem. I need to use FrameLayout inside of ScrollView for making it scrollable. I wrote this <ScrollView android:id=”@+id/scrollView1″ android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true” android:background=”#00ff00″> <FrameLayout android:id=”@+id/frameLayout” android:layout_width=”match_parent” android:layout_height=”500dp” android:background=”#ff0000″> </FrameLayout> </ScrollView> But this doesn’t work. I tried in RelativeLayout and it worked, but I need to […]

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