Tag: layout

What is the difference between linear and relative layout?

What is the difference between linear and relative layout?

setBackgroundColor in android

In this simple game I want to change the background color of the button that I press. But I get the following result, the buttons appearance becomes not good (the shape becomes different): pressedButton.setBackgroundColor(Color.RED); Is there a nicer way to do that? Thanks. [Edit: my full code] package com.example.xo_game; import android.os.Bundle; import android.app.Activity; import android.graphics.Color; […]

How to set alpha value for my Relative layout?

Hi I’m trying to set alpha value for my relative layout but, i am getting error how to solve this help me….. I have three layout in my xml layout 1st layout using for background 2nd layout using for header 3rd layout using for footer. I wish to set alpha value 2 & 3rd layout […]

How to let the ImageView and the TextView the same height

My layout have ImageView(iv) and TextView(tv). I want to let the tv right of iv. And the tv’s height is same as iv’s. The tv Gravity set as CENTER_VERTICAL. <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/RelativeLayout1″ android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > <ImageView android:id=”@+id/iv” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:layout_alignParentTop=”true”/> <TextView android:id=”@+id/tv” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:layout_alignParentTop=”true” android:layout_toRightOf=”@+id/iv” android:text=”TextView” android:gravity=”center_vertical”/> </RelativeLayout> How […]

How to inflate RelativeLayout from XML

I got a very specific task to inflate view. To be honest i dont really understand what I should do exactly. The only method, which compiled probperly was that @Override public View getView(int position, View convertView, ViewGroup parent) { //TODO – Get the current ToDoItem final ToDoItem toDoItem = mItems.get(position); //TODO – Inflate the View […]

basics of device-independent-pixels

im throughoutly confused by dips on Android. I understand from the reference that the base for dp values is 160. So, shouldn’t 80dp in width equals a view with a width of 50% of the screen ? On my Nexus One the width in dp is something around 300dp as it seems. What am i […]

Why Is Custom View not Invalidating?

Im a noob to android development and I am having problems invalidating a view. I am using this tutorial and have no issues implementing it. However, when I change the background of the view, it still responds as if the previous background is still set. In other words, I change the mask but my “touchview” […]

Margins and paddings between elements in LibGDX

I have a VerticalGroup of Buttons on my screen. The problem is that buttons located very closely one to one. I want to add some spaces between buttons, something like padding or margin. I find pad method in Table in API, but VerticalGroup doesn’t extends Table and therefore doesn’t contain this method. Please point me […]

Xml layout changes while changing orientation

I have two activities which opens depending on the SD card presence. One activity has three Buttons and a TextView and the other an ImageView, a button and zoom control. When I change the orientation, the buttons get scrambled around while in horizontal direction. How to go around this? My ‘SD’ card layout <?xml version=”1.0″ […]

programatically change layout height, ClassCastException?

I’m trying to “animate” a WebView to drop down and reveal its contents. I’ve written a handler to increase the height by 1 each time, however, i’m running into a ClassCastException. The code i’m using is: WebView.LayoutParams params = new WebView.LayoutParams(wv.getLayoutParams()); params.height = height; wv.setLayoutParams(params); height++; this.sleep(20); On the line wv.setLayoutParams(params), I get a: java.lang.ClassCastException: […]

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