Tag: layout

Right aligning text in android?

Is there anything special I need to do to get text right aligned in a <TableLayout>? The following simple example seems to align the text right-edged on the center of the screen, almost as if layout_span had no effect. <TableLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”fill_parent” android:layout_width=”fill_parent” > <TableRow> <TextView android:text=”Some text” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_gravity=”right” android:layout_span=”2″ /> </TableRow> <TableRow> […]

Android Relative Layout circular dependencies error

Hi im trying to create a custom layout but i’m struggling to get it to work properly i’m getting an error “circluar dependencies cannot exist in Relative layout” heres what im trying to acheive in termas of layout and then fill each text field with data. date number name score – score name scorers scorers […]

Android layout with square buttons

I want to make a layout similar to this one: www.ImageBanana.net – layout.png http://www.imagebanana.com/img/9kmlhy66/thumb/layout.png Four square buttons on the screen – each of those using half of the screen with/screen height (whichever is smaler). Independent of screen size/resolution. I already tried to achieve this by using a LinearLayoutbut the buttons are ending up using the […]

Should use “sp” instead of “dp” for text sizes

When I use android:textSizes=”20dp” in my XML for a textView, I got a warning “Should use “sp” instead of “dp” for text sizes.” Why should “dp” not be used? What is the correct approach? How can I achieve same textsizes on different displays?

RuntimeException while using new TextInputLayout from support design library

I have very simple layout where I use new android.support.design.widget.TextInputLayout view from Design Support Library <android.support.design.widget.TextInputLayout android:id=”@+id/til” android:layout_width=”fill_parent” android:layout_height=”wrap_content”> <EditText android:id=”@+id/textDialog” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:hint=”First Name”/> </android.support.design.widget.TextInputLayout> On inflate I get exception: Caused by: java.lang.RuntimeException: Failed to resolve attribute at index 18 at android.content.res.TypedArray.getColor(TypedArray.java:401) at android.support.design.widget.CollapsingTextHelper.setCollapsedTextAppearance(CollapsingTextHelper.java:166) at android.support.design.widget.TextInputLayout.<init>(TextInputLayout.java:106)             at java.lang.reflect.Constructor.newInstance(Native Method)             at java.lang.reflect.Constructor.newInstance(Constructor.java:288)             at android.view.LayoutInflater.createView(LayoutInflater.java:607)             at […]

Please verify my layout: bottom button keeps coming up over keyboard

I have a layout which does almost what I want. There’s just one bug regarding the button at the bottom. I should stay at the bottom at all times. But whenever I bring up the soft-keyboard the button will be displayed above the keyboard. This is not what I want but it should become covered […]

Storing hex color values in strings.xml

I’m trying to store the hex color value of my text in strings.xml so all the layout files will refer to that (to be able to quickly change all layout text for the project easily) however I’m having trouble referring to it. Using android:textColor=”#FFFFFF” in my xml layout works fine. However using android:textColor=”@strings/textColor” gives me […]

Layout buttons so each divides up the space equally

Im using a LinearLayout to put two buttons horizontally side-by-side, but I want to each button to size itself to use 50% of the horizontal space. I thought layout_weight of “1” for each button would do the trick, but maybe my layout_width needs to be changed?

Android relative layout with button width using weight

I’ve used the layout_weight parameter to set the width of the buttons at 70% of the total layout width, but it seems I’m missing some important detail in order to make it work. (Another solution would be to work with display.getWidth() programmatically, but it doesn’t work either, because I don’t know what my .xml should […]

how to set android progress bar in center of the screen

I am trying to show the progress bar in the center of the screen, but it doesn’t show up in the center. Below is my layout. What am i doing wrong here? Basically this is a layout to show image and android gallery widget on top. When the user clicks on the thumbnails, I am […]

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