Tag: layout

Android: put element below another element and align at bottom of screen

I am trying to define a layout where an ImageView is aligned at the bottom of the screen and also under a GridView, to avoid overlapping. This however results in the ImageView being set just under the GridView but not aligned with the bottom of the screen. Can this be solved using a different kind […]

Modifying the Android seekbar widget to operate vertically

I’m trying to get a vertical seekbar going with the emulator, but I’m sort of stuck. I can get the seekbar to display the way I want it to, and I can get the progress to do what I want, and I can modify the onTouchEvent to get the thumb to go vertically instead of […]

Storing dimensions in xml file in Android

I am trying to consistently use the same dimension in all the views in my android app (e.g., a left margin of 20dp). If I were using HTML, I would simply use a CSS file, but I am at a loss of how to do this on Android. Is there a way I can store […]

Android: automatically make variables for all IDs in xml

I noticed one of the most tedious parts of Android development is the layout design, even with layout builder. After setting up the graphics, then the layout, making variable associations with the layout elements is very tedious, such as ImageButton myButton = (ImageButton)findViewById(R.id.myButton); in larger layouts, these can get tedious to keep track of (recalling […]

Custom ListView and context menu. How to get it?

I have a two layouts files in my app. Also I have Activity extends ListActivity. Every item of this activity looks consider item.xml layout file. I am trying to get context menu when make long presss on item, but I don’t see it. In my activity I trying to registerForContextMenu(getListView()) and override two methods @Override […]

selector not working with layout and image view

I want to use selector for a layout and image view..But it is not working for me. When I changed image view to imagebutton or button, it works fine. Any help will be greatly appreciated.. Thanks in advance.. here is the xmls I used.. <?xml version=”1.0″ encoding=”utf-8″?> <selector xmlns:android=”http://schemas.android.com/apk/res/android”> <!– When selected, use grey –> […]

Android: How to automatically display vertical scrollbar?

I created a user form which fits the window in vertical orientation. When the user slides the keyboard the form doesn’t fit the screen (horizontal orientation). I tried to add the scrollbar but it is not visible. I would appreciate if anyone could show how to modify the following layout file in order to display […]

Android Design Support TabLayout overlapping content

I am using the new TabLayout introduced in the design support library. I have the code like this: <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_height=”match_parent” android:layout_width=”match_parent”> <android.support.design.widget.CoordinatorLayout android:id=”@+id/lines_coordinator” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.design.widget.AppBarLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar”> <android.support.design.widget.TabLayout android:id=”@+id/tabs” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:elevation=”4dp”/> </android.support.design.widget.AppBarLayout> <android.support.v4.view.ViewPager android:id=”@+id/viewpager” android:layout_width=”match_parent” android:layout_height=”match_parent” /> </android.support.design.widget.CoordinatorLayout> </LinearLayout> The problem is, that the tabs overlap the top of the content […]

Best practices for dealing with expensive view height calculation?

I keep running into a sizing and layout problem for custom views and I’m wondering if anyone can suggest a “best practices” approach. The problem is as follows. Imagine a custom view where the height required for the content depends on the width of the view (similar to a multi-line TextView). (Obviously, this only applies […]

Android: How do I change the height of a ProgressBar?

I was wondering what is the easiest way to change the height of a ProgressBar in Android? Thanks, Tomek

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