Tag: layout

Make a SurfaceView transparent without setZOrderOnTop(true)

I have a RelativeLayout containing a custom SurfaceView and other elements that must be drawn over the SurfaceView. I also need the SurfaceView to be transparent. I tried this answer: how to make surfaceview transparent. But with the setZOrderOnTop(true) the other elements over the SurfaceView in the RelativeLayout are shown above the Surface (and partially […]

How can I make a `View` fill a `RelativeLayout`?

I have a RelativeLayout with some stuff in it, and I want a background view to fill the whole thing. This is what I would expect to work: <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:background=”#000″ > <View android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_alignParentLeft=”true” android:layout_alignParentRight=”true” android:layout_alignParentTop=”true” android:layout_alignParentBottom=”true” android:layout_margin=”1px” android:background=”#fafafa” /> <ImageView android:id=”@+id/im” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:layout_centerVertical=”true” android:src=”@drawable/ic_blank_profile” /> …. and so on. […]

Strange behaviour when using WebView and RelativeLayout in fullscreen

EDIT: Here’s the video showing the problem: www.youtube.com/watch?v=5ZZsuMH5T9k I’m really stuck here :/ — I have an activity which consists of a webview and a button at the bottom. I set the window of the activity to fullscreen using this code in onCreate: @Override public void onCreate(Bundle savedInstanceState) { InstaFetchApplication.applyCurrentTheme(this); super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); requestWindowFeature(Window.FEATURE_PROGRESS); if (UserPreferences.getIsFullScreenReadingEnabled(this)) […]

ImageView: fill horizontal maintaining aspect ratio

I need an ImageView scale it image until fill the parent horizontally. If the imageview background is red, and the rest of the content (below the image) is the green I’m looking for the result shown by the Picture 1. That result is obtained automatically if the image width is higher than the screen width. […]

Android get screen size in XML

Hey I have a scrollview from the top of the screen to a bit before the bottom of the screen because this is where my ad banner takes place. I want to have some pixels in between these elements ( between buttons and banner ) due the google policy. So far I did this with […]

Android: Creating a parent layout and extending it to maintain an identical look and feel across all activities of the application

I am writing an app in which I have mutiple screens which I want to adhere to a certain theme. For example: all screens should have the same background, all screens should have a bar on the top with the same set of actions (not necessarily dependent on the activity currently being show) and all […]

How do I center a GridView in its LinearLayout parent?

GridView is not behaving like it is supposed to. This screenshot shows that the GridView (in landscape mode) is flushed left. I want it centered. This is the XML layout for the GridView. <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/templatelandscape” android:orientation=”horizontal” android:layout_width=”fill_parent” android:layout_height=”wrap_content”> <GridView android:id=”@+id/commandsbarlandscape” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_weight=”1.0″ android:layout_alignParentTop=”true” android:layout_centerInParent=”true” android:padding=”0dp” android:verticalSpacing=”2dp” android:horizontalSpacing=”2dp” android:numColumns=”auto_fit” android:columnWidth=”52dp” android:stretchMode=”spacingWidth” android:gravity=”fill_horizontal” /> </LinearLayout> […]

How to switch or change between the tabs in android sdk graphical layout?

I am trying to change or switch between two tabs that I have within the eclipse graphical layout so that I can see the elements on the other tab. Is this possible? the only way I could see of doing this is to make the second tab, briefly be the first as that is what […]

Setting a max width for LinearLayout

How can I set the max width of my horizontal LinearLayout? So if the contents are short (say, some text), the layout shrinks and if the contents are longer, it will not expand more than some max width value. I prefer doing this at the XML level.

Can an Android View's id be safely shared across multiple Activities?

Say I have two Activities in an Android application, EditPerson and EditEmployee. It would seem natural to have the EditPerson Activity be a base class for the EditEmployee Activity and define methods that marshal data to and from the Views defined in the layout. The EditPerson Activity’s implementation would push (for example) the “Name” field […]

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