Tag: android-layout

center items horizontally in RecyclerView(using GridLayoutManager)

I’m trying to center all my items horizontally for each row in RecyclerView I tried many things: RelativeLayout as a parent, then use layout_centerInParent, use the basic android:layout_gravity=”center”, try to add some space element,using weights and …. in item_row.xml but I didn’t succeed 🙁 What i have What i want In activity recyclerView.setLayoutManager(new GridLayoutManager(this, 3)); […]

SurfaceView lags if in ScrollView

I have a SurfaceView in a ScrollView. Whenever I try to scroll, the SurfaceView always lags a bit behind leaving black seams where it doesn’t cover the space where it has to be. My code for the SurfaceView is: <SurfaceView android:layout_width=”match_parent” android:layout_height=”200dp” android:id=”@+id/fragment_stats_hourly_surface_view” android:layout_below=”@+id/fragment_stats_hourly_view” android:layout_marginLeft=”16dp” android:layout_marginRight=”16dp” android:background=”@drawable/outline” /> How can I set the SurfaceView to […]

Have horizontal RadioButtons wrap if too long for screen

So I have the following radiobuttons. I want to have them display like this: However this occurs: How I can get it to display like above? I can move in the GUI editor in Eclipse it but it removes the RadioButton from the RadioGroup!Within the group, it ignores all other layout parameters. <RadioGroup android:id=”@+id/radioGroup1″ android:layout_width=”wrap_content” […]

Not removing the padding around button text

I have written a code to change the minWidth of a button so that I can get rid of the padding around the button text. for(int i=0;i<26;i++){ Button alphabet = new Button(getContext()); alphabet.setText(“”+(char)(‘A’+i)); alphabet.setMinWidth(0); allAlphabets.addView(alphabet); } I am having a letter in each button and finally adding it to a layout dynamically. Due to padding, […]

ConstraintLayout aspect ratio

Consider the following layout file: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” xmlns:tools=”http://schemas.android.com/tools” android:layout_width=”match_parent” android:layout_height=”match_parent”> <android.support.constraint.ConstraintLayout android:id=”@+id/activity_main” android:layout_width=”match_parent” android:layout_height=”match_parent” android:background=”#FF0000″ android:paddingBottom=”@dimen/activity_vertical_margin” android:paddingLeft=”@dimen/activity_horizontal_margin” android:paddingRight=”@dimen/activity_horizontal_margin” android:paddingTop=”@dimen/activity_vertical_margin”> <ImageView android:layout_width=”0dp” android:layout_height=”0dp” android:background=”#0000FF” android:padding=”16dp” app:layout_constraintBottom_toBottomOf=”parent” app:layout_constraintTop_toTopOf=”parent” app:layout_constraintLeft_toLeftOf=”parent” app:layout_constraintDimensionRatio=”H,3:1″ tools:layout_editor_absoluteX=”16dp” /> </android.support.constraint.ConstraintLayout> </RelativeLayout> I am not sure how the app:layout_constraintDimensionRatio works. My understanding is the ratio will always be width:height. So 3:1 […]

How to make HorizontalScrollView RIGHT to LEFT Scroll android

By default HorizontalScrollView scrolls from Left to Right but I want to scroll from Right to Left. How to do this? Any help will be appreciated.

Android Design Navigation Drawer – How to add a switch in nav xml?

I am using the new Android Design Navigation Drawer. I want to add a switch in the drawer. Is there a away to implement this? this is the menu xml: <menu xmlns:android=”http://schemas.android.com/apk/res/android”> <group android:id=”@+id/nav_view_menu_group_1″ android:checkableBehavior=”single”> <item android:id=”@+id/nav_view_menu_item_myschedule” android:icon=”@drawable/ic_navview_my_schedule” android:title=”@string/navview_menu_item_myschedule” android:titleCondensed=”@string/navview_menu_item_myschedule” /> <item android:id=”@+id/nav_view_menu_item_iolive” android:icon=”@drawable/ic_navview_play_circle_fill” android:title=”@string/navview_menu_item_iolive” android:titleCondensed=”@string/navview_menu_item_iolive” android:visible=”false”/> <item android:id=”@+id/nav_view_menu_item_explore” android:icon=”@drawable/ic_navview_explore” android:title=”@string/navview_menu_item_explore” android:titleCondensed=”@string/navview_menu_item_explore” /> <item android:id=”@+id/nav_view_menu_item_map” […]

Gingerbread devices not using Holo style from Theme.AppCompat (support library)

I’m using the v4 and v7 support library to integrate the action bar and navigation drawer in my app, which supports API 10+. I’ve followed the guide on the developer site to use Theme.AppCompat and style/Widget.AppCompat.ActionBar as the parent of my theme and action bar style, respectively. Everything works fine, except when I test on […]

Why using Fragments?

I have read the documentation and some other questions’ threads about this topic and I don’t really feel convinced; I don’t see clearly the limits of use of this technique. Fragments are now seen as a Best Practice; every Activity should be basically a support for one or more Fragments and not call a layout […]

How to increase space between text and it's underline in TextView Android?

I want to increase space between text and it’s underline. I can change line height but I don’t change height between text and it’s underline.How can I do this ? private static final String FONTH_PATH = “fonts/Brandon_bld.otf”; … selectTextView = (TextView) findViewById(R.id.selectTextView); selectTextView.setTypeface(font); SpannableString content = new SpannableString(getResources().getString(R.string.select_your_prove_type)); content.setSpan(new UnderlineSpan(), 0, content.length(), 0); selectTextView.setText(content); … […]

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