android-layout

How to catch exceptions caused by a malformed layout-xml file?

public class MyActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //R.layout.main has an illegal element (e.g. no layout_height attribute) //But no e...

How to set footer in android

How to set footer in android on each page I have used: <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:background="@color/mcolor" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_gravity="fill"> <ImageButton ...

Browser-like layout, how to achieve?

I'm trying to create a layout similar to the browser application. Basically, I want to have a LinearLayout on top of a WebView in such a way that when the user starts scrolling the WebView, the LinearLayout scrolls away, too (like the address bar in the browser app). I know I could have the two elements inside a LinearLayout inside a Sc...

Android. Default text color

Hallo everybody, I'd like to use black color as default text color only in one activity. I guess, I should use Theme and Styles, but I didn't find any good information relating to my question or to only one activity. Is it possible to change default text color only for one activity? If yes, could you give me an example please, how t...

Android XML Layout

How do i define a following layout in my xml file: I hope you got it from image that i want to display TextView1 on 1st Row, and in 2nd Row, TextView2 on Left and TextView3 on Right side. How do i define this layout? i know the layout_gravity attribute but not getting success, so pls share your code ...

Aligning with center in android with hierarchical Layouts.

Why doesn't the following code align with the center? What do I have to do to fix it? <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_gravity="center" android:id="@+id/parent" android:layout_height="match_parent" android:layout_width="match_parent" android:background=...

Navigation through pages

Hello. I'm very very new on Android development. I have designed two xmls layouts (main.xml and secondpage.xml). I want to go from main.xml to secondpage.xml when the user click on a button. I've found on android's documentation the following methods: startActivity startActivityForResult and more and more methods... Should may us...

Android: Add event listeners to every item in a ListView

I have an Android app with a ListView, and each row in the list has a TextView and a Button. What I want to do is add an OnClickListener to each Button in the ListView, but I can't figure out how to get some sort of reference to every Button... Can anyone please give me a hint? Here's my XML that's bound to the ListAdapter: <RelativeLa...

Tell android that my layout can be resized instead of cropped

How can I tell android to not crop my layout when displaying the on-screen keyboard but to instead resize it? ...

[Android] How to check the type of a view widget?

How to get that working: if(findViewById(ResIdWithUnkownType) instanceof Bitmap) { Bitmap bitmap = (Bitmap) findViewById(ResIdWithUnkownType); } else if(findViewById(ResIdWithUnkownType) instanceof ImageView) { ImageView = (ImageView) findViewById(ResIdWithUnkownType); } ...

[Android] How to exchange an image in a layer-list by a bitmap?

Here is my Bitmap Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(url).getContent()); //Need some code to access "dynamicItem" and exchange it with my Bitmap And here is my layer list (nothing spectacular). I want to exchange the dynamicItem with my Bitmap. <?xml version="1.0" encoding="utf-8"?> <layer-list ...

two directional scroll view

I would like to have a linearlayout with a header section on top and a webview below. The header will be short and the webview may be longer and wider than the screen. What is the best way to get horizontal and vertical scrolling? Is a ScrollView nested inside a HorizontalScrollView a good idea? ...

EditText alignment, within a LinearLayout that has a 9 Patch background image.

<LinearLayout android:id="@+id/LinearLayout03" android:background="@drawable/ninepatch" android:layout_width="wrap_content" android:layout_height="55dip" android:layout_weight="1"> <LinearLayout android:id="@+id/LinearLayout02" android:layout_width="wrap_content" android:layout_height="wrap_content"> <EditText android:id="@+id/EditText...

Include a second layout resource in my first one

Is there a way to include one resource in another (for example a header design in multiple activities' layouts). I know I can add it at run time, can it be done in the XML? ...

Is it possible to change the scale of the sp unit

In my XML I can set textSize="18sp". Is it possible to change the scale of the sp unit which would affect all sp sizes but not affect dp sizes? ...

Is it possible to adjust the scale of the dp unit to affect all the XML layout resources?

(preferably not by using recursively changing size after having done setContentView) ...

min height fill_parent and height wrap_content in ScrollView? (or just the email app compose layout's code)

Question If I have the following: <ScrollView android:layout_width="fill_parent" android:layout_height="fill_parent"> <LinearLayout android:layout_width="fill_parent" android:layout_height="?" android:orientation="vertical"> <EditText android:layout_width="fill_parent" android:layout_height="?" android:hint="Subject" android...

Help needed for creating an Android Activity Layout - Screenshot given

Hello Experts, I need to create a screen(scrollable) exactly similar to the screenshot shown here . I have no idea regarding the kind of layout patterns that I should resort to or the widgets that I should use. The data including thumbnail links, is available dynamically. Experts, kindly help with your valuable suggestions, advices a...

Relativelayout programatically in android

I'm having trouble finding exactly the syntax I need to use to set the paramters on child views of a relative layout. I have a root relative layout that I want to set 2 child textviews next to each other like this ---------- --------- | Second | | First | ---------- --------- So I have public class RL extends RelativeLayout{ ...

Android layout broken with 9-patch background

Hey, I encountered this problem when updating my background to use a 9-patch image. The layout is fine on different screens using different sizes of the same image, but when I change the image to be a 9-patch it breaks the entire layout mysteriously. The previous layout looks like this: . When changed to 9-patch: . The XML file rem...