Tag: android-layout

TextView setGravity() doesn't work in java

I’m stuck on a problem and I don’t know, what causes it. I have a very simple Layout like this: <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:orientation=”vertical”> <TextView android:id=”@+id/my_text_view” android:layout_width=”wrap_content” android:layout_height=”fill_parent” android:layout_gravity=”NOTE_THIS” android:textColor=”#FFFFFF” android:textSize=”22dp” android:text=”TestText”/> </LinearLayout> which is included inside another layout. If I change the gravity inside the xml I see same Result […]

Android remove button dynamically

I have a button and when I press it, i want to remove it (not make it invisible). I read that I can do that using layout.removeView(mybutton) but what is the layout ? and how can I get it in my activity Button showQuestion; private void initialize() { showQuestion = (Button) findViewById(R.id.bAnswerQuestionShowQuestion); } public void […]

how to give border for tablerow in tablelayout in android?

I need to show border around TableRow in TableLayout. How would i do that???

How to map a list of list to RecyclerView

I am trying to map a List<List<Object>> to a RecyclerView in Android, but the result is totally messed up. For example, I have a list of list like this (just for explaining, not my real case): List<List<String>> list = {{a, b, c}, {d, e}, {f, g, h, i}}; the Recyclerview should display like (first row […]

Fragments inside ViewPager dissapear when orientation changes

I have read several posts (http://tinyurl.com/pb8es74, http://tinyurl.com/p9pcfcv…) about this but cannot find a solution. I have a MainActivity which loads a layout containing a ViewPager with three fragments (which have different layouts depending on orientation). I have added this feature to the activity so it is not destroyed when the orientation changes as I might […]

Child Views Taking too much time to draw on screen

I have android layout design in which I have an AppBar layout which will contain a Toolbar and one more LinearLayout design with circle Drawable as TextView. which is off same height. So when I try to get the Toolbar or AppBar height/width it’s returning only 0. activity_main.xml: <android.support.design.widget.AppBarLayout android:id=”@+id/app_bar” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:theme=”@style/ThemeOverlay.AppCompat.Dark.ActionBar” app:layout_behavior=”@string/appbar_scrolling_view_behavior”> <android.support.v7.widget.Toolbar […]

Dynamically updating TabLayout without changing selected tab

I want to implement a wizard with Material Design Support library. I’m using ViewPager and Tablayout but I have a problem adding new tabs dynamically. First, I set up my widgets in onCreate method: viewPager = (ViewPager) findViewById(R.id.tab_viewpager); tabLayout = (TabLayout) findViewById(R.id.tab_layout); adapter = new ViewPagerAdapter(getSupportFragmentManager()); adapter.addFrag(new DummyFragment(), “1”); adapter.addFrag(new DummyFragment(), “2”); viewPager.setAdapter(adapter); tabLayout.setupWithViewPager(viewPager); Then […]

Animating layouts using the “animateLayoutChanges” attribute in XML

I have a LinearLayout, for which I apply android:animateLayoutChanges=”true” in the parent LinearLayout. When the user clicks a toggle button, the LinearLayout “collapses” (I set the view’s visibility as LinearLayout.GONE programmatically, and when they click it again, it expands by programmatically setting the visibility back to LinearLayout.VISIBLE. The animation of it collapsing and expanding works […]

AutoCompleteTextView strange behaviour in LolliPop Device

I am using AutoCompleteTextView in my layout. But it’s colorControlNormal and Activate is not Working as I expected. My Color value is #0072BA. Below is figure for Different Device. 1.) Android Kitkat 2.) Android LolliPop 3.) Android Marshmallow Xml code that i used is below <TextView android:layout_width=”match_parent” android:layout_height=”wrap_content” android:textColor=”@color/md_black_1000″ android:layout_marginTop=”5dp” android:textSize=”15sp” android:text=”Medical Store Name” android:textColorHint=”#999999″ […]

Stick view at the bottom of the fragment of a viewpager inside coordinator layout

I have a viewpager which is placed inside a coordinator layout. In a particular fragment of a viewpager i have a recycler view and a view at the bottom of the fragment. The problem is that initially the view at bottom of the fragment is hidden and is visible only when i scroll upwards. I […]

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