Tag: layout

Why is my progress bar not centered vertically?

I have the following 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=”@drawable/bg_generic_portrait”> <ListView android:id=”@android:id/list” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:background=”@drawable/issue_list_item_background_normal” android:listSelector=”@drawable/issue_background_selector” android:divider=”@drawable/separator” > </ListView> <ProgressBar android:layout_width=”wrap_content” android:layout_height=”fill_parent” android:layout_gravity=”center” android:id=”@+id/preloader” style=”@android:style/Widget.ProgressBar.Large”/> <TextView android:id=”@android:id/empty” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”#FF0000″/> </LinearLayout> And it looks like this…http://i.stack.imgur.com/Ra5c6.png I want the preloader to be centered vertically too, what is wrong?

How do I prepend a String to an Android TextView?

There’s TextView.append(), but that adds the text to the end of the TextView. I want what I append to go in the beginning (ie, show up on the top of the TextView box).

Change layout while orientation change at runtime in a fragment without recreating the view

I try to develop a first app that download images from the net and show them in a gridview. The gridview is a fragment of a main Activity. The download process is made with an AsyncTask in the onCreate Function. In order not to download again the images while changing orientation, i set the android:configChanges=”orientation|screenSize” […]

Android percentage width layout

I need to set the width of my view as 50% of the width of the screen and then center this view horizontally while potentially having 1 or more buttons which can appear attached to the left or the right side of the screen. I’m using a relative layout so that I can place a […]

how to align parent bottom in android linear layout?

I have a linearlayout and I want to create at the bottom of it a slice. I know there are some options, but I’m a bit confused 1) android:layout_gravity:”bottom” –> this doesn’t work for me for some reason. 2) android:gravity_weight=”0″ and give the sibling before it android:gravity_weight:”1″ 3) android:height=”wrap_content” and give the sibling before it […]

android ClassCastException on findViewById

I’ve got a little problem where I can’t find the mistake I am making, it’s probably something really simple. I’ve got the following layout <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_marginLeft=”10dp” > <CheckBox android:id=”@+id/checkBox” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentLeft=”true” android:focusable=”false” /> <ImageView android:id=”@+id/imgStarred” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignRight=”@+id/checkBox” android:layout_below=”@+id/checkBox” android:layout_marginRight=”4dp” android:src=”@drawable/ic_star_gray”/> <CheckedTextView android:id=”@+id/lblTitle” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignTop=”@+id/checkBox” android:layout_marginLeft=”10dp” android:layout_marginTop=”8dp” […]

Android:How can I set the AlertDialog width and height,and the button of the AlertDialog style?

I have a task to change the AlertDialog width and height by xml,I want make that become style,so I can use it easy.And that ,I need to change button of AlertDialog style also.Can you tell me a way to achieve the target。Thank you Very grateful。 PS,I’d better achieve the target by change xml。

Android complex layout linear and relative

I have to implement a layout like shown in the diagram, and I do not know the best combination to achieve the required design. I’m designing for the 7″ tablet and want the design to stretch well on the 10″ I assume layouts like 1, 2, 3, 4, 5 are LinearLayouts, correct? *What is the […]

Custom list item to ListView android

I have been playing with the list activity tutorial here: http://developer.android.com/resources/tutorials/views/hello-listview.html which tells you to start off extending List activity. by public class Main extends ListActivity { Which is based on inflating a textview only layout. <?xml version=”1.0″ encoding=”utf-8″?> <TextView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:padding=”10dp” android:textSize=”16sp” > </TextView> If I want to customize the layout more […]

Relations between dip, px and dpi

If, in a layout xml file, I set the size to be, for example 12dip. Will that always be 12px in mdpi and so 18px in hdpi? So is dip always true for mdpi and will scale accordingly for other densities?

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