Tag: android-layout

How to immediately replace the current toast with a second one without waiting for the current one to finish?

This question already has an answer here: How to prevent Multiple Toast Overlaps 7 answers

How to set the background color of a WebView to a hex value?

How do I set the background color of a WebView to a hexadecimal value? I am open to either via main.xml or programmatically.

Understanding BaseAdapters and how to use them

I’m trying to set up a an image GridView Layout, and this involves deriving a new class from the BaseAdapter class. I have been using the tutorial on the website developer.android.com, but I still don’t quite understand what it means. Could someone please explain to me what exactly is a BaseAdapter? I don’t understand the […]

Android Display HTML in a ListView

Sorry if this is obvious to everyone else but I am having a minor difficulty understanding how to display html inside my listview. My list view is declared. ListView lv1 = (ListView) findViewById(R.id.ListView01); I populate it (not shown) then set my listview here with an ArrayAdapter. lv1.setAdapter(new ArrayAdapter<String>(SearchByFood.this, R.layout.new_list_view, foods)); Further down I create a […]

Android: Align LinearLayout center for all screen sizes

I want to design a layout for my login screen, I tried the following codes. Using some hardcoded values I got my center green color layout center for some screen sizes. I know using hardcoded values wont work on different screen sizes. I tried numerous stuffs on SO. Please provide me the best way <?xml […]

Using version 1.0.0-alpha7 of the constraint library, which is obsolete

I’m starting using Android Studio 2.2 and trying to play with ConstraintLayout but when I let android studio add it automatically it showed me that error Using version 1.0.0-alpha7 of the constraint library, which is obsolete when I try to upgrade it using quick fix I get that error Error:Could not find com.android.support.constraint:constraint-layout:1.0.0-alpha8. I think […]

How to remove default layout's padding/margin

I have the following layout files: activity_main.xml <FrameLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” xmlns:map=”http://schemas.android.com/apk/res-auto” android:id=”@+id/frame_container” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:layout_marginLeft=”0px” android:layout_marginRight=”0px” android:layout_marginTop=”0px” android:padding=”0dp” > … </FrameLayout> And some other fragments like fragment_init.xml: <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:tools=”http://schemas.android.com/tools” android:id=”@+id/fragmentInit” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:padding=”0dp” android:layout_marginTop=”0px” android:layout_marginLeft=”0px” android:layout_marginRight=”0px” android:background=”#549F07″ > <TextView … > … </RelativeLayout> Everything looks fine in Lint, but when I execute my application […]

How to Prevent Keyboard appearing for EditText that is not enabled

My activity has an EditText which is supposedly not editable until user clicks on edit button for the screen. I did edit.setEnabled(false) but still a keyboard appears for the user and values can be added to the EditText in the screen via the keyboard even though the screen might look a bit greyed out. What […]

android:layout_weight=“33” how does gone->visible visible->gone effect this?

android layouts use a layout_weight. I am aiming for 1/3 for all components but sometimes the footer is literally set to gone, and then visible. How does the weight calculation work when setting from gone to visible? I am not seeing the content inside a linear layout which has 1/3 weight?

Invoking a search or filter on an Android ListFragment?

I’m using the Android compatibility library, and I’m using a ListFragment. I have it set up to display the items in my list quite nicely. However, now I want to give the users the ability to filter/search the data. How do I set this up? Is it any different then it was with the regular […]

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