Tag: layout

Center elemets of HorizontalScrollView when not enough to make it scroll

I have a Layout with a HorizontalScrollView containing a LinearLayout for a Menu where the contents are inflated with the contents of the DB. This works fine however when there are not enough elements to make the HSV scroll this does not fill the width of the screen which ideally should be centered. i.e. Currently: […]

Can't override textAllCaps for buttons on style under android 21

This is how I set my buttons. <Button android:id=”@+id/button_login” style=”@style/ButtonStyle” android:text=”@string/button_login” /> This is my style on values folder. <style name=”ButtonStyle” parent=”ButtonStyleBase” /> <style name=”ButtonStyleBase”> <item name=”android:layout_width”>match_parent</item> <item name=”android:layout_height”>wrap_content</item> <item name=”android:layout_marginTop”>@dimen/padding</item> <item name=”android:textSize”>@dimen/font_regular</item> <item name=”android:textColor”>@color/text_regular</item> <item name=”android:background”>@drawable/shape_clickable</item> </style> And this is my style on values-v21 folder <style name=”ButtonStyle” parent=”ButtonStyleBase”> <item name=”textAllCaps”>false</item> <item name=”android:textColor”>#000000</item> </style> But […]

Android background + text + icon for a button

I would like to have an image set to background a text on it and an icon on the left side of the text. Very easy in iPhone, but can’t figure out how to do it at Android, to be resizable that button and keep the icon + text position and distance properly. iPhone: Android […]

Layout Animation Android

I want to Animate two Different layouts. Example I already have the animation the way I want, I just want to animate a different XML Layout. There is a class LayoutAnimationController, but I really dont know how to use it. Can some one point me in the right direction, with an example or good explanation. […]

This RelativeLayout layout or its LinearLayout parent is useless

I’m developing an Android 3.1. and above application. On one activity I generate its layout dynamically. I’m using formdetail.xml as contentview: @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.formdetail); Bundle extras = getIntent().getExtras(); if (extras != null) { currentFormId = extras.getString(“FormId”); } } formdetail.xml : <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:id=”@+id/detailLayout” android:layout_width=”match_parent” android:layout_height=”match_parent” android:orientation=”vertical” > […]

LinearLayout does not fill the scrollview

<ScrollView android:layout_width=”fill_parent” android:id=”@+id/scrollView1″ android:layout_height=”fill_parent”> <LinearLayout android:id=”@+id/linearLayout1″ android:layout_width=”fill_parent” android:orientation=”vertical” android:layout_height=”fill_parent”> <ListView android:id=”@+id/listView1″ android:layout_width=”fill_parent” android:layout_height=”fill_parent”></ListView> </LinearLayout> </ScrollView> The scrollview fill the whole screen but the linearLayout1 fill just small part of the screen something near 100dip in height. How can I make the linearLayout1 to fill the parent ?

Android: How do I retrieve Edittext.getText() in custom AlertDialog?

The topic explains what i’m after… I can’t retrieve the EditText from my custom view in android. All I get is a Nullpointer Exception. :/ I’ve marked where the problems are in the code with comments. The ID:s are correct and my XML layout is a simple RelativeLayout containing two EditText attributes. Obviously I’m missing […]

Fade effect between layouts

As by object, I would reproduce fade effect between two layout. Now I’ve this situation: LinearLayout l; LinearLayout l2; To switch between them I’ve used l.setVisibility(View.GONE); l2.setVisibility(View.VISIBLE); I want add fade effect between this transiction, how I can do it?

Set the width of relativelayout 1/3 the width of the screen?

I have a layout like below. Now, I don’t want to set the width of relative layout to fixed 240 dp. I want to set the width of the relative layout to 1/3 the width of the screen. Is it possible to do that in the xml file. If it is impossible, how can I […]

What do I have to add to a layout to hide the titlebar?

I want to hide the titlebar of my app in some of my views. What do I have to add to the layout files I want to hide the titlebar in? Can you provide an example?

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