Tag: android-layout

How to set height of one layout component to the same height of another component?

How can I set one layout components height to the same as another component: example: Can I set android:layout_height=”@+id/info_box.height” or do something similar? I want the height of the ImageView to match that of my LinearLayout ImageView android:id=”@+id/border” android:src=”@drawable/frame” android:layout_below=”@+id/title” android:layout_width=”fill_parent” android:layout_height=”????” android:scaleType=”fitXY” android:drawingCacheQuality=”auto” /> <LinearLayout android:id=”@+id/info_box” android:orientation=”vertical” android:layout_below=”@+id/title” android:background=”@layout/my_bg” android:layout_width=”fill_parent” android:layout_height=”wrap_content” > … other […]

Android Distorted UI

I am not able to find the root cause of the below distortion. UI works fine but when I rotate the screen to landscape, the UI gets distorted while scrolling. This distortion continues when the screen is again rotated to portrait. <?xml version=”1.0″ encoding=”utf-8″?> <ScrollView xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”match_parent” android:layout_height=”match_parent” android:layout_margin=”8dp”> <LinearLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:orientation=”vertical”> <include layout=”@layout/i_details” […]

How can display my scroll layout above the keyboard?

Am using a scrollview inside a relative layout. I could be able to scroll to end of the page in all mobiles when without keyboard, in some mobiles i could be able to view scroll layout completely when the keyboard is on. ie)- the end of the scrollview above the keyboard. The problem i have […]

Progressbar on the background of list item

I want background of a list item to work like a progress bar. For example, like in tTorrent file list: This is how it is done now: I use a relativelayout and two linearlyouts. One has textviews and another has two views which work as progressbar. “Progress” is changed using weight of the views, which […]

Android Night Mode without CarModeEnabled

So I made separate xmls for night mode and kept them in layout-night. Then I switch to night mode: UiModeManager uiManager = (UiModeManager) getSystemService(Context.UI_MODE_SERVICE); if (nightMode) { uiManager.enableCarMode(0); uiManager.setNightMode(UiModeManager.MODE_NIGHT_YES); } else { uiManager.disableCarMode(0); uiManager.setNightMode(UiModeManager.MODE_NIGHT_NO); } Is it possible to set night mode without enabling car mode? or for that matter possible to use layout-night, values-night […]

Application crashing only on lollipop devices

Application is working fine on all OS, but when i add facebook SDK, it gives me following error message on lollipop devices. compile ‘com.facebook.android:facebook-android-sdk:4.20.0′ Caused by: java.lang.ClassNotFoundException: Didn’t find class “retrofit2.Retrofit$Builder” on path: DexPathList[[zip file “/data/app/com.myapp.app-3/base.apk”, zip file java.lang.NoClassDefFoundError: Failed resolution of: Lretrofit2/Retrofit$Builder; Caused by: java.lang.ClassNotFoundException: Didn’t find class “retrofit2.Retrofit$Builder” on path: DexPathList[[zip file “/data/app/com.myapp.app-3/base.apk”, […]

change position of spinner dropdown list

I need to change the horisontal position of Spinner’s dropdown list. here’s the screenshot : and I want this dropdown list to go in one line under the main icon/text so it would look fine As on the picture : here’s what I do in xml : <Spinner android:id=”@+id/tvHeader” style=”@style/spinner_style” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignBottom=”@+id/ver_main_donate_background_tile_long” android:layout_alignTop=”@+id/ver_main_donate_background_tile_long” android:layout_marginTop=”5dp” […]

LinearLayout overlapping Support CoordinatorLayout

It’s the first time I use CoordinatorLayout, and I don’t really understand how it works. My LinearLayout is overlapping my Toolbar, as if I were in a FrameLayout, or RelativeLayout, and I don’t know how to tell it to go below ( Like android:layout_below with RelativeLayout ) Here is my code: <android.support.design.widget.CoordinatorLayout xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:app=”http://schemas.android.com/apk/res-auto” android:id=”@+id/main_content” […]

Swipe to delete listitem

I would like to implement a swipe gesture to delete rows in a ListView similar to the android notifications. Right now all I have is a ListView with an onTouchListener – that said, I already have swipe detection working. gestureDetector = new GestureDetector(this, new GestureListener()); onTouchListener = new TouchListener(); listview.setOnTouchListener(onTouchListener); My GestureListener class: protected class […]

How to set layout dynamically in android

Well, Suppose there is an Activity called MainActivity and there are two layouts called layout1 and layout2 both have few buttons. By default MainActivity layout is layout1 like following: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.layout1); Now what I did actually is by clicking a button in layout1 the second layout is set like following: […]

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